1from secret import clue
2
3
4def lucky():
5 left_three_bits = clue(right_shift=5)
6 right_three_bits = clue(left_shift=5)
7 middle_left_bit = clue(bw_and=1 << 4)
8 middle_right_bit = clue(bw_or=255 ^ (1 << 3))
9 result = []
10 first_bits = [2, 1, 0]
11 for bit_index in first_bits:
12 result.append(get_bit_at_position(left_three_bits, bit_index))
13
14 if middle_left_bit:
15 result.append(1)
16 else:
17 result.append(0)
18
19 if middle_right_bit == 255:
20 result.append(1)
21 else:
22 result.append(0)
23
24 last_bits = [7, 6, 5]
25 for bit_index in last_bits:
26 result.append(get_bit_at_position(right_three_bits, bit_index))
27 return int("".join(map(str, result)), 2)
28
29
30def get_bit_at_position(number, position):
31 mask = 1 << position
32 if number & mask:
33 return 1
34 return 0
.
----------------------------------------------------------------------
Ran 1 test in 0.005s
OK