The implementation of the 2018 Criminal Investigation Section of reasoning Test Python

Source: Internet
Author: User

The more the problem is that it should be written in a program, so it's written in Python, why use Python, because it's really handy.

First to see if theoretically feasible, 10 questions, 4 options per question, that is, 4 10 power, 2 power of 20, that is, the 20bit,2.5byte data to traverse, the order of the general computer is properly enough, 4Byte or less usually can, if 20 is 5Byte is more difficult, 6Byte will be a few weeks, 8Byte do not think, of course, is traversed, if in front of the results of the exception.

Here is the Python source code:

Ask_all = 0;

ask = [0,0,0,0,0,0,0,0,0,0];

While Ask_all < 2**20:

For I in range (10):

Ask[i] = ((Ask_all >> (2*i)) & 0x03);

Ask_all = Ask_all + 1;

#ASK2

select = [2,3,0,1]

If select[ask[1]]! = Ask[4]:

Continue

#ASK3

Flag = 0;

select = [2,5,1,3]

For i in select:

if (ask[i] = = Ask[select[ask[2]]) & (i! = Select[ask[2]]):

flag = 1;

Break

If flag = = 1:

Continue

#ASK4

select = [[0,4],[1,6],[0,8],[5,9]]

If ask[select[ask[3]][0]]! = ask[select[ask[3]][1]]:

Continue

#ASK5

select = [7,3,8,6]

If ASK[SELECT[ASK[4]] "! = Ask[4]:

Continue

#ASK6

select = [[1,3],[0,5],[2,9],[4,8]]

if (ask[select[ask[5]][0]]! = ask[7]) | (Ask[select[ask[5]][1]]! = ask[7]):

Continue

#ASK7

select = [2,1,0,3]

Count = [Ask.count (0), Ask.count (1), Ask.count (2), Ask.count (3)]

If SELECT[ASK[6]]! = Count.index (min (count)):

Continue

#ASK8

select = [6,4,1,9]

if (ask[select[ask[7]] [= (ask[0]+1)) | (Ask[select[ask[7]] = = (ask[0]-1)):

Continue

#ASK9

select = [5,9,1,8]

If ask[0] = = Ask[5]:

If ask[select[ask[8]] [= ask[4]:

Continue

Else

If ASK[SELECT[ASK[8]] "! = Ask[4]:

Continue

#ASK10

select = [3,2,4,1]

If SELECT[ASK[9]]! = (max (count)-min (count)):

Continue

For I in range (10):

Print I+1,

Print (");

For I in ask:

Print Chr (Ord (' A ') +i),

Results:

The implementation of the 2018 Criminal Investigation Section of reasoning Test Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.