1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
import itertools
A = 'A' B = 'B' C = 'C' D = 'D' E = 'E'
def Q1(): options = { A : answer[2], B : answer[3], C : answer[4], D : answer[5], E : answer[6], } option = options[answer[1]] return option == B
def Q2(): options = { A : (answer[2], answer[3]), B : (answer[3], answer[4]), C : (answer[4], answer[5]), D : (answer[5], answer[6]), E : (answer[6], answer[7]), } option = options[answer[2]] count = sum([(x[0] == x[1]) for x in options.values()]) return (option[0] == option[1]) and (count == 1)
def Q3(): options = { A : answer[1], B : answer[2], C : answer[4], D : answer[7], E : answer[6], } option = options[answer[3]] return option == answer[3]
def Q4(): options = { A : 0, B : 1, C : 2, D : 3, E : 4, } option = options[answer[4]] return option == answer.count(A)
def Q5(): options = { A : answer[10], B : answer[9], C : answer[8], D : answer[7], E : answer[6], } option = options[answer[5]] return option == answer[5]
def Q6(): options = { A : B, B : C, C : D, D : E, E : None, } option = options[answer[6]] if option == None: counts = [answer.count(x) for x in [B, C, D, E]] return answer.count(A) not in counts return answer.count(A) == answer.count(option)
def Q7(): options = { A : 4, B : 3, C : 2, D : 1, E : 0, } option = options[answer[7]] return option == abs(ord(answer[7]) - ord(answer[8]))
def Q8(): options = { A : 2, B : 3, C : 4, D : 5, E : 6, } option = options[answer[8]] count = answer.count(A) + answer.count(E) return option == count
def Q9(): options = { A : (2, 3, 5, 7), B : (1, 2, 6), C : (0, 1, 4, 9), D : (0, 1, 8), E : (0, 5), } option = options[answer[9]] count = 10 - answer.count(A) - answer.count(E) return count in option
def Q10(): options = { A : A, B : B, C : C, D : D, E : E, } option = options[answer[10]] return option == answer[10]
answers = itertools.product([A, B, C, D, E], repeat=10) for answer in answers: answer = [''] + list(answer) if Q1() and Q2() and Q3() and Q4() and Q5() and \ Q6() and Q7() and Q8() and Q9() and Q10(): print(''.join(answer)) break
|