Skip to content

Commit

Permalink
day22 part1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrenault committed Dec 22, 2024
1 parent 2ce17d1 commit f51b02a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions advent/advent2024/day22.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from advent.utils.utils import Advent

advent = Advent(22, 2024)


def main():
lines = advent.get_input_lines()
secrets = list(map(int, lines))
evolved = []
for secret in secrets:
for _ in range(2000):
secret = evolve(secret)
evolved.append(secret)

advent.submit(1, sum(evolved))


def evolve(secret: int) -> int:
secret ^= secret * 64
secret %= 16777216
secret ^= int(secret / 32)
secret %= 16777216
secret ^= secret * 2048
secret %= 16777216
return secret


if __name__ == "__main__":
main()

0 comments on commit f51b02a

Please sign in to comment.