advent-of-code/2024/22/one.py
2024-12-25 12:59:49 +01:00

30 lines
540 B
Python

#!/usr/bin/env python3
import sys
input_file = sys.argv[1]
with open(input_file) as fd:
lines = [line.rstrip() for line in fd.readlines()]
def prng(secwet: int) -> int:
secwet ^= secwet * 64
secwet %= 16777216
secwet ^= secwet // 32
secwet %= 16777216
secwet ^= secwet * 2048
secwet %= 16777216
return secwet
tot = 0
for line in lines:
secwet = int(line)
print(f"Init {secwet=}")
for i in range(2000):
secwet = prng(secwet)
print(f" -> {secwet=}")
tot += secwet
print(tot)