diff --git a/.aoc_tiles/tiles/2024/21.png b/.aoc_tiles/tiles/2024/21.png new file mode 100644 index 0000000..1094c33 Binary files /dev/null and b/.aoc_tiles/tiles/2024/21.png differ diff --git a/.aoc_tiles/tiles/2024/22.png b/.aoc_tiles/tiles/2024/22.png new file mode 100644 index 0000000..b492d1f Binary files /dev/null and b/.aoc_tiles/tiles/2024/22.png differ diff --git a/2024/22/example b/2024/22/example new file mode 100644 index 0000000..07b41ba --- /dev/null +++ b/2024/22/example @@ -0,0 +1,4 @@ +1 +10 +100 +2024 diff --git a/2024/22/example_p2 b/2024/22/example_p2 new file mode 100644 index 0000000..201df76 --- /dev/null +++ b/2024/22/example_p2 @@ -0,0 +1,4 @@ +1 +2 +3 +2024 diff --git a/2024/22/script.py b/2024/22/script.py new file mode 100644 index 0000000..a64459e --- /dev/null +++ b/2024/22/script.py @@ -0,0 +1,28 @@ +from GhostyUtils import aoc + + +def prune(number: int) -> int: + return number % 16777216 + + +def evolve(number: int, repeat: int = 1) -> int: + for r in range(repeat): + number ^= number * 64 + number = prune(number) + + number ^= number // 32 + number = prune(number) + + number ^= number * 2048 + number = prune(number) + + return number + + +def main(): + inputs = list(map(int, aoc.read_lines())) + print(f"p1: {sum(evolve(i, 2000) for i in inputs)}") + + +if __name__ == "__main__": + main() diff --git a/README.md b/README.md index d71534b..9e374e2 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ My solutions to the yearly Advents of Code