1from secret import clue
2
3
4def lucky():
5 accumulated_number = 0x00
6 shifted_left = clue(left_shift=5) # ABCD EFGH -> FGH0 0000
7 accumulated_number += shifted_left >> 5 # 0000 0FGH
8
9 shifted_right = clue(right_shift=5) # ABCD EFGH -> 0000 0ABC
10 accumulated_number += shifted_right << 5 # ABC0 0FGH
11
12 bw_and_mask = 0x08 # 0000 1000
13 bw_or_mask = 0xef # 1110 1111
14
15 bw_and_clue = clue(bw_and=bw_and_mask) # ABCD EFGH -> 0000 E000
16 bw_or_clue = clue(bw_or=bw_or_mask) # ABCD EFGH -> 111D 1111
17
18 accumulated_number += bw_and_clue # ABC0 EFGH
19 bw_or_clue &= 0x10 # 000D 0000
20 accumulated_number += bw_or_clue # ABCD EFGH
21
22 return accumulated_number & 0xff # не съм сигурен че не стърчат някви битове извън 8-те
.
----------------------------------------------------------------------
Ran 1 test in 0.004s
OK
| f | 1 | f | 1 | ||
| 2 | from secret import clue | 2 | from secret import clue | ||
| 3 | 3 | ||||
| 4 | 4 | ||||
| 5 | def lucky(): | 5 | def lucky(): | ||
| 6 | accumulated_number = 0x00 | 6 | accumulated_number = 0x00 | ||
| 7 | shifted_left = clue(left_shift=5) # ABCD EFGH -> FGH0 0000 | 7 | shifted_left = clue(left_shift=5) # ABCD EFGH -> FGH0 0000 | ||
| 8 | accumulated_number += shifted_left >> 5 # 0000 0FGH | 8 | accumulated_number += shifted_left >> 5 # 0000 0FGH | ||
| 9 | 9 | ||||
| 10 | shifted_right = clue(right_shift=5) # ABCD EFGH -> 0000 0ABC | 10 | shifted_right = clue(right_shift=5) # ABCD EFGH -> 0000 0ABC | ||
| 11 | accumulated_number += shifted_right << 5 # ABC0 0FGH | 11 | accumulated_number += shifted_right << 5 # ABC0 0FGH | ||
| 12 | 12 | ||||
| 13 | bw_and_mask = 0x08 # 0000 1000 | 13 | bw_and_mask = 0x08 # 0000 1000 | ||
| 14 | bw_or_mask = 0xef # 1110 1111 | 14 | bw_or_mask = 0xef # 1110 1111 | ||
| 15 | 15 | ||||
| 16 | bw_and_clue = clue(bw_and=bw_and_mask) # ABCD EFGH -> 0000 E000 | 16 | bw_and_clue = clue(bw_and=bw_and_mask) # ABCD EFGH -> 0000 E000 | ||
| 17 | bw_or_clue = clue(bw_or=bw_or_mask) # ABCD EFGH -> 111D 1111 | 17 | bw_or_clue = clue(bw_or=bw_or_mask) # ABCD EFGH -> 111D 1111 | ||
| 18 | 18 | ||||
| 19 | accumulated_number += bw_and_clue # ABC0 EFGH | 19 | accumulated_number += bw_and_clue # ABC0 EFGH | ||
| 20 | bw_or_clue &= 0x10 # 000D 0000 | 20 | bw_or_clue &= 0x10 # 000D 0000 | ||
| t | 21 | accumulated_number += () # ABCD EFGH | t | 21 | accumulated_number += bw_or_clue # ABCD EFGH |
| 22 | 22 | ||||
| 23 | return accumulated_number & 0xff # не съм сигурен че не стърчат някви битове извън 8-те | 23 | return accumulated_number & 0xff # не съм сигурен че не стърчат някви битове извън 8-те | ||
| 24 | 24 |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||