four suspects
ABCD 4 suspects, A said B did it, B said D did it, C said I didn't do it, D said B was lying.
Only one of them told the truth ( ) was a criminal
Only one of the 4 people did something bad, so there are only 4 cases. For the answers of 1000, 0100, 0010, and 0001, it is only necessary to judge how many truths and how many falsehoods there are in each answer, and the case where the truth is 1 is the answer.
10 Criminal Investigation Reasoning Test Questions
In this question, the most important information is: multiple-choice questions, if you ignore this condition, you will get
10 questions with multiple answers, each question has 4 answers, and there are a total of $4^10=2^20$ options Select the answers and verify that each answer is self-sufficient.
def get_ans_of(ans, i):
return (ans >> ((i - 1) * 2)) & 3
def only_one(ans_list, my_ans):
return len(ans_list) == 1 and ans_list[0] == my_ans
def one(ans):
return True
def two(ans):
five_ans = get_ans_of(ans, 5)
second_ans = get_ans_of(ans, 2)
return five_ans == (2, 3, 0, 1)[second_ans]
def three(ans):
def diff_from_other(ans_list, i):
for j in range(len(ans_list)):
if j != i:
if ans_list[i] == ans_list[j]:
return False
return True
ans_group = [get_ans_of(ans, i) for i in (3, 6, 2, 4)]
real_ans = []
for i in range(4):
if diff_from_other(ans_group, i):
real_ans.append(i)
return only_one(real_ans, get_ans_of(ans, 3))
def four(ans):
same_group = ((1, 5), (2, 7), (1, 9,), (6, 10))
real_ans = []
for i in range(4):
if get_ans_of(ans, same_group[i][0]) == get_ans_of(ans, same_group[i][1]):
real_ans.append(i)
return only_one(real_ans, get_ans_of(ans, 4))
def five(ans):
options = (8, 4, 9, 7)
real_ans = []
for i in range(4):
if get_ans_of(ans, options[i]) == get_ans_of(ans, 5):
real_ans.append(i)
return only_one(real_ans, get_ans_of(ans, 5))
def six(ans):
group = ((2, 4,), (1, 6), (3, 10), (5, 9))
real_ans = []
for i in range(len(group)):
x, y = group[i]
x_ans = get_ans_of(ans, x)
y_ans = get_ans_of(ans, y)
if x_ans == get_ans_of(ans, 8) and y_ans == get_ans_of(ans, 8):
real_ans.append(i)
return only_one(real_ans, get_ans_of(ans, 6))
def seven(ans):
cnt = [0] * 4
for i in range(1, 11):
cnt[get_ans_of(ans, i)] += 1
mi = 0
for i in range(4):
if cnt[i] < cnt[mi]:
mi = i
mi_count = 0
for i in range(4):
if cnt[i] == cnt[mi]:
mi_count += 1
if mi_count != 1:
return False
return mi == (2, 1, 0, 3)[get_ans_of(ans, 7)]
def eight(ans):
options = (7, 5, 2, 10)
real_ans = []
for i in range(4):
if abs(get_ans_of(ans, options[i]) - get_ans_of(ans, 1)) != 1:
real_ans.append(i)
return only_one(real_ans, get_ans_of(ans, 8))
def nine(ans):
one_six_same = get_ans_of(ans, 1) == get_ans_of(ans, 6)
options = [6, 10, 2, 9]
real_ans = []
for i in range(4):
x5_same = get_ans_of(ans, options[i]) == get_ans_of(ans, 5)
if x5_same != one_six_same:
real_ans.append(i)
return only_one(real_ans, get_ans_of(ans, 9))
def ten(ans):
cnt = [0] * 4
for i in range(1, 11):
cnt[get_ans_of(ans, i)] += 1
real_ans = max(cnt) - min(cnt)
return real_ans == (3, 2, 4, 1)[get_ans_of(ans, 10)]
def tos(ans):
s = []
for i in range(1, 11):
s.append("ABCD"[get_ans_of(ans, i)])
return ''.join(s)
def judge(ans):
for i in (one, two, three, four, five, six, seven, eight, nine, ten):
if not i(ans):
return False
return True
def main():
for i in range(4 ** 10):
if judge(i):
print(tos(i))
if __name__ == '__main__':
main()
The answer is: BCACA CDABA
Although such questions can be enumerated with violence, the human brain can plan an optimal reasoning path, and can get answers quickly without considering many situations. This is the same as Sudoku and vertical word puzzles that I like to play. .
It would be a huge step forward for machine reasoning if we could decipher the heuristics of how humans think about problems!