您的位置:首页 > 其它

2018刑侦推理试题

2018-03-04 18:45 253 查看
今天闺蜜发了一个刑侦科推理试题,我看了两下就想编程爆破,可怕,我竟然丧失了推理能力吗!!!



既然已经编程求解了,我就先把代码粘上来吧,然后我现在尝试自己去推一下,要是推出来我会补上推理过程的。

# -*- coding:utf-8 -*-
s = "ABCD"
def test(str):
if(str[4]=='C' and  str[1]=='A') or (str[4]=='D' and str[1]=='B') or (str[4]=='A' and str[1]=='C') or ((str[4]=='B' and str[1]=='D')):
if(str[2]=='A'  and str[5]==str[1] and str[3]==str[1] and str[1]!='A') or(str[2]=='D'  and str[5]==str[1] and str[1]=='D' and str[3]!='D') or(str[2]=='C'  and str[5]==str[3] and str[3]=='C' and str[1]!='C') or(str[2]=='B'  and str[1]==str[3] and str[3]=='B' and str[5]!='B'):
if(str[3]=='A' and str[0]==str[4]) or(str[3]=='B' and str[1]==str[6])or(str[3]=='C' and str[0]==str[8])or(str[3]=='D' and str[5]==str[9]):
if(str[4]=='A' and str[7]==str[4]) or(str[4]=='B' and str[3]==str[4])or(str[4]=='C' and str[8]==str[4])or(str[4]=='D' and str[6]==str[4]):
if(str[5]=='A' and str[1]==str[3] and str[1]==str[7])or(str[5]=='B' and str[0]==str[5] and str[0]==str[7])or(str[5]=='C' and str[2]==str[9] and str[2]==str[7])or(str[5]=='D' and str[4]==str[8] and str[4]==str[7]):
l = [0, 0, 0, 0]
for i in str:
l[ord(i)-ord('A')]+=1
min = l[0]
max = l[0]
ch = 0
for i in xrange(1, 4):
if(min>l[i]):
min = l[i]
ch = i
if(max<l[i]):
max = l[i]
aa = chr(i+ord('A'))
if(aa=='A'  and str[6]=='C')or(aa=='B'  and str[6]=='B')or(aa=='C'  and str[6]=='A')or(aa=='D'  and str[6]=='D'):
a = ord(str[6])-ord(str[0])
b = ord(str[4])-ord(str[0])
c = ord(str[1])-ord(str[0])
d = ord(str[9])-ord(str[0])
if(abs(a)!=1  and str[7]=='A') or (abs(b)!=1  and  str[7]=='B') or (abs(c)!=1  and  str[7]=='C') or (abs(d)!=1  and  str[7]=='D'):
if(str[0]=
cb83
=str[5]  and  str[5]!=str[4] and str[8]=='A')or(str[0]==str[5]  and  str[9]!=str[4] and str[8]=='B')or(str[0]==str[5]  and  str[1]!=str[4] and str[8]=='C')or(str[0]==str[5]  and  str[8]!=str[4] and str[8]=='D')or(str[0]!=str[5]  and  str[5]==str[4] and str[8]=='A')or(str[0]!=str[5]  and  str[9]==str[4] and str[8]=='B')or(str[0]!=str[5]  and  str[1]==str[4] and str[8]=='C')or(str[0]!=str[5]  and  str[8]==str[4] and str[8]=='D'):
max_min = max - min
if(max_min==3 and str[9]=='A')or(max_min==2 and str[9]=='B')or(max_min==4 and str[9]=='C')or(max_min==1  and  str[9]=='D'):
return True
else:
return False
else:
return False
else:
return False
else:
return False
else:
return False
else:
return False
else:
return False
else:
return False
else:
return False
def main():
for a in s:
for b in s:
for c in s:
for d in s:
for e in s:
for f in s:
for g in s:
for h in s:
for i in s:
for j in s:
res = a+b+c+d+e+f+g+h+i+j
#print res
if test(res):
print res
main()


在室友的提示下,有了如下假设推理。从第2题找突破口,假设第2题依次选ABCD,然后逐渐推理找出没有矛盾的一组答案。

<1> 假设第2题选A

则第5题选C, 第9题选C(因为5,2答案不相同,所以第9题中后者命题为假,前者命题为真,于是第1题和第6题答案相同)

设1和6均选A

则从6选A知2、4、8题答案相同均为A, 那么根据第三题知道2,3,4,6有三题答案相同,一题答案不同,这里2, 4, 6均选A,那么第三题与其它不同,这样第3题也选A,推出矛盾

设1和6均选B

则从6选B知1, 6, 8题答案相同均为B,那么根据第三题一共只有两个答案,则这两个答案是2的A和6的B。若第三题选C,矛盾,出现了第三个答案;若第三题选B, 矛盾,B不是与其他三项答案不同的答案

设1和6均选C

则从6选C知3, 8, 10三题答案相同,又因为2, 3, 4, 6中只能有两种答案,那么就是A,C,所以第3题答案只能是A或C

(1)若3,8,10答案均为A

那么(由第三题知)2,4,6答案相同均为C,而假设中2的答案为A,矛盾

(2)若3, 8, 10答案均为C

那么(由第三题知)2, 4, 6答案相同,而假设中2的答案是A, 6的答案是C,矛盾

设1和6答案均为D

则由6选D知5, 8, 9答案相同均为C,则2,3,4,6一共有两种答案A和D,若第3题选C,则有3种答案,矛盾;若第3题选B,则也有3种答案,矛盾

<2> 设第2题选B

则第5、7题答案均为D,由第7题选D知D的字母个数2最少,则A,B,C均至少有3个字母,3+3+3+2>10矛盾

<3>设第2题选C

则第5,8题均选A

2,3,4,6的两种答案有一种是C

若第3题选C,则C答案不止一个,矛盾

若第3题选A,则2, 4, 6答案均为C,由第6题选C知3, 8, 10答案相同均为A,现在还有1, 7, 9答案未定,且由4选C知1,9答案相同,由10选A知最多次与最少次相差3

(1)假设1与9均为A

9为A,5,6答案又不相同,说明前面命题为真,1和6答案应该相同,又1为A,6位C,矛盾

(2)假设1与9均为B

9为B,5,10答案相同,说明前面命题为假,1,6答案应该不同,又1位B,6位C,确实不同,这时答案1B2C3A4C5A6C7 8A9B10A,这时A有4个,C有3个,B有2个,7选D刚好满足所有条件。

所以最终答案是BCACACDABA
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: