1from secret import clue
2
3
4def lucky():
5 """Find the lucky number"""
6
7 first_three_bits = clue(right_shift=5)
8 fourth_bit = clue(bw_or=239) # 11101111(239) | my_num -> saves 4th bit, sets others to 1
9 fifth_bit = clue(bw_and=8) # 00001000(8) & my_num -> saves 5th bit, sets others to 0
10 last_three_bits = clue(left_shift=5)
11
12 last_three_bits >>= 5
13 first_three_bits <<= 5
14 fourth_bit ^= 239 # 11101111(239) ^ fourth_bit -> saves 4th bit, sets 1s to 0s
15
16 address = 0 # 00000000 for mask
17 address |= first_three_bits
18 address |= fourth_bit
19 address |= fifth_bit
20 address |= last_three_bits
21
22 return address
.
----------------------------------------------------------------------
Ran 1 test in 0.004s
OK
f | 1 | from secret import clue | f | 1 | from secret import clue |
2 | 2 | ||||
n | n | 3 | |||
3 | def lucky(): | 4 | def lucky(): | ||
n | n | 5 | """Find the lucky number""" | ||
6 | |||||
4 | first_three_bits = clue(right_shift=5) | 7 | first_three_bits = clue(right_shift=5) | ||
t | 5 | fourth_bit = clue(bw_or=239) # 11101111(239) | myNum -> saves 4th bit, sets others to 1 | t | 8 | fourth_bit = clue(bw_or=239) # 11101111(239) | my_num -> saves 4th bit, sets others to 1 |
6 | fifth_bit = clue(bw_and=8) # 00001000(8) & myNum -> saves 5th bit, sets others to 0 | 9 | fifth_bit = clue(bw_and=8) # 00001000(8) & my_num -> saves 5th bit, sets others to 0 | ||
7 | last_three_bits = clue(left_shift=5) | 10 | last_three_bits = clue(left_shift=5) | ||
8 | 11 | ||||
9 | last_three_bits >>= 5 | 12 | last_three_bits >>= 5 | ||
10 | first_three_bits <<= 5 | 13 | first_three_bits <<= 5 | ||
11 | fourth_bit ^= 239 # 11101111(239) ^ fourth_bit -> saves 4th bit, sets 1s to 0s | 14 | fourth_bit ^= 239 # 11101111(239) ^ fourth_bit -> saves 4th bit, sets 1s to 0s | ||
12 | 15 | ||||
13 | address = 0 # 00000000 for mask | 16 | address = 0 # 00000000 for mask | ||
14 | address |= first_three_bits | 17 | address |= first_three_bits | ||
15 | address |= fourth_bit | 18 | address |= fourth_bit | ||
16 | address |= fifth_bit | 19 | address |= fifth_bit | ||
17 | address |= last_three_bits | 20 | address |= last_three_bits | ||
18 | 21 | ||||
19 | return address | 22 | return address |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|