We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 12ec873 commit 5efb40bCopy full SHA for 5efb40b
2024/solutions/day22.py
@@ -15,16 +15,14 @@ def map_sequence(n):
15
n = ((n << 11) ^ n) & 0xffffff
16
17
value = n % 10
18
-
19
- if i >= 3:
20
- # Use key as a compact hash of the last 4 diff values, using 5 bits
21
- # per value ([-9, 9] -> [1, 19]) with 0 meaning "no value".
22
- key = ((key & 0x7fff) << 5) | (value - prev + 10)
23
- if key not in diff_map:
24
- diff_map[key] = value
25
+ # Use key as a compact hash of the last 4 diff values, using 5 bits
+ # per value ([-9, 9] -> [1, 19]) with 0 meaning "no value".
+ key = ((key & 0x7fff) << 5) | (value - prev + 10)
26
prev = value
27
+ if i >= 3 and key not in diff_map:
+ diff_map[key] = value
+
28
return n, diff_map
29
30
0 commit comments