blob: 235472606aea6b8b2cef3772769dfc664bdd6e50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
from fileinput import input
from itertools import islice
lines = [int(line.strip()) for line in input()]
def prices(secret):
x = secret
while True:
yield x
x ^= x << 6
x &= 0xFFFFFF
x ^= x >> 5
x &= 0xFFFFFF
x ^= x << 11
x &= 0xFFFFFF
silver = sum(next(islice(prices(x), 2000, None)) for x in lines)
gold = 0
print("silver:", silver)
print("gold:", gold)
|