From 5a667ed2f66a7c5a40b67756cc1eca34fdf89d89 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Thu, 4 Dec 2025 09:19:49 +0100 Subject: [PATCH] 2025(04): WIP, I will try to fix it later --- 2025/04/README.md | 49 ++++++++++++++++ 2025/04/input | 138 ++++++++++++++++++++++++++++++++++++++++++++++ 2025/04/part1.py | 46 ++++++++++++++++ 2025/04/testinput | 10 ++++ 4 files changed, 243 insertions(+) create mode 100644 2025/04/README.md create mode 100644 2025/04/input create mode 100644 2025/04/part1.py create mode 100644 2025/04/testinput diff --git a/2025/04/README.md b/2025/04/README.md new file mode 100644 index 0000000..0f5e5f6 --- /dev/null +++ b/2025/04/README.md @@ -0,0 +1,49 @@ +# Day 4: Printing Department + +[https://adventofcode.com/2025/day/4](https://adventofcode.com/2025/day/4) + +## Description + +### Part One + +You ride the escalator down to the printing department. They're clearly getting ready for Christmas; they have lots of large rolls of paper everywhere, and there's even a massive printer in the corner (to handle the really big print jobs). + +Decorating here will be easy: they can make their own decorations. What you really need is a way to get further into the North Pole base while the elevators are offline. + +"Actually, maybe we can help with that," one of the Elves replies when you ask for help. "We're pretty sure there's a cafeteria on the other side of the back wall. If we could break through the wall, you'd be able to keep moving. It's too bad all of our forklifts are so busy moving those big rolls of paper around." + +If you can optimize the work the forklifts are doing, maybe they would have time to spare to break through the wall. + +The rolls of paper (`@`) are arranged on a large grid; the Elves even have a helpful diagram (your puzzle input) indicating where everything is located. + +For example: + + ..@@.@@@@. + @@@.@.@.@@ + @@@@@.@.@@ + @.@@@@..@. + @@.@@@@.@@ + .@@@@@@@.@ + .@.@.@.@@@ + @.@@@.@@@@ + .@@@@@@@@. + @.@.@@@.@. + + +The forklifts can only access a roll of paper if there are _fewer than four rolls of paper_ in the eight adjacent positions. If you can figure out which rolls of paper the forklifts can access, they'll spend less time looking and more time breaking down the wall to the cafeteria. + +In this example, there are _`13`_ rolls of paper that can be accessed by a forklift (marked with `x`): + + ..xx.xx@x. + x@@.@.@.@@ + @@@@@.x.@@ + @.@@@@..@. + x@.@@@@.@x + .@@@@@@@.@ + .@.@.@.@@@ + x.@@@.@@@@ + .@@@@@@@@. + x.x.@@@.x. + + +Consider your complete diagram of the paper roll locations. _How many rolls of paper can be accessed by a forklift?_ diff --git a/2025/04/input b/2025/04/input new file mode 100644 index 0000000..541b1a8 --- /dev/null +++ b/2025/04/input @@ -0,0 +1,138 @@ +@.@...@@.@.@@@@@@.@@@@.@..@@..@.@@@.@@@@@..@@@.@.@@...@@..@@@@.@@@@@@@@@@@@@..@.@@@@.@.@.@@@.@@.@.@.@..@@@@@@@....@@@@...@@...@.@@@.@@@.@. +@@..@@@@...@.@@@..@@.@.@@@@....@@@@@@..@@@.@@@....@.@@.@@@@..@...@.@.@@.@@@@@.@@.@@..@@.@@@@@@.@..@.@@@@@.@@@.@@.@.@@@@@@.@@@@.@.@@.@..@@@ +@@@@..@.@.@..@@.@.@@@...@@@@@..@..@.@@@@@.@..@.@.@.@@@.@@.@@@.@.@@.@@.@@@.@@.@@.@@..@.@@@.@@.@@.@@@@.@@@.@@@@@@@....@.@@@@@@@@@@.@.@@@@@.. +.@@@@@@.@@@@.@@.@..@@@.@..@@@@@@.@@@@@...@@.@@@@.@@.@..@@@@@.@@@@.@@....@@@..@.@@..@@@@@.@..@@@.@@@@.@@..@@@.@@@.@@.@..@..@.@@@@@@@@.@@@@@ +.@@@...@..@.@@@.@@@..@@..@.@..@@@..@.@@@.@.@.@@@@@.@@.@.@@@@.@.@@.@@@@.@@@@@@@.@.@..@@.@@@@.@....@@@@...@@@...@@..@..@.@..@@@@@@.@@.@.@@.. +@@@.@@@..@@@.@@@.@.@@..@@..@.@@@@@.@@.@..@..@@@@@@.@@@.@@@@.@@@@@@@..@@@@.@@@.@@@@@.@.@@@@.@.@..@.@@@@.@@@.@@.@@.@@@@.@.@..@.@..@@.@...@@. +@@..@@@.@......@.@@@.@@@.@@.@@.@@..@@@...@@@@@...@.@.@....@@@@@@@.@@..@@.@@@.@@.@@@@..@@@..@...@@@.@@.@.@..@@.@@.@.@@.@@.@@@.@@@.@@@.@@.@@ +@@.@...@.@@@@@.@@@@.@@@@@...@.@.@@.@.@@..@@@@@.@.@@@@@@@@@@@@@.@..@@@@@.@@.@@@.@..@.@.@@@..@@@.@@@.@@.@@..@@@.@@.@@@@@@.@.@@@.@.@@@@.@.@.@ +.@.@.@..@.@.@..@@@.@@.@@@@@@@.@@.@@.@...@@@.@@.@@.@.@@@@@@.@.@@@.@@.@@@@@...@.@@.@@.@@@@...@.@@.@@@@@@@@.@@@@.@.....@@@.@@.@.@@@@@@@@..@@@ +@@@@@.@@.@..@@@.....@@.@@@@..@@@@@.@@@@.@@.@@.@@@@@@.@..@@@@..@@@@@..@.@@@@@@..@@@@@@.@..@..@@.@@@@.@@.@.@@@@@@..@@@.@@..@@@...@@.@@...@@@ +.@@.@@@@@@.@@@.@@.@@.@@@.@.@.@@@@.@.@@@@@@@@@@@@.@.@@@....@..@@.@@@@...@.@....@@@@@..@.@@@..@@@@@.@...@.@@@...@...@.@@@@@.@.@...@.@.@@@@.@ +@@.@...@@....@@..@@@@@.@@.@.@@..@.@.@@@@.@@@@@@@@@@@@@....@@@@@@@@.@..@@...@.@@@.@.@.....@@@.@@@@@.@.@.@@@@@@@@.@.@@.@@.@@@@.@@@@@@...@.@@ +@@@@..@@..@.@@@@@.@.@.@.@@@@@@@@.@....@.@.@.@@@@..@.@@..@..@@@@.@@.@..@.@..@@.@.@@@@@.@@@@@@@@@@@..@.@@.@@@@.@..@.@@.@@@@.@@@@@.@.@@@@.@@. +@@@@@.@..@.@@@@@.@@@@@@.@@@@.@@@@@..@.@@@.@@.@.@@@@@@@@@@@@.@@@.@..@.@@.@@@.@@.@@.@@@@@@@@@@@@...@@@@.@@@.@.@@@.@@@.....@@.@@@.@@.@.@@@@.@ +..@.@@.@.@@@@.@@.@@@@@@@@@@@@.@@@@@@@.@..@@.@.@@.@@@@.@.@@@@@@@@.@.@@@@.@@@..@@..@@..@@@@@@..@@..@.@@.@.@.@@.@...@.@@.@@@@..@.@@@@@@@@@.@@ +@@@@@.@@..@...@..@@@.@@@.@@..@..@.@..@.@@@.@@.@@...@@.@@@@@.@@..@.@@@.@..@@.@@@.@@..@@@.@@@@..@@.@@@.@.@@@@@.@@.....@.@@@...@.@@@.@@@@@.@@ +@@@@@@.@@@.@@@@@.@@@@@.@@..@@.@...@@..@.@....@@@@.@..@@@@...@@..@@@@@@.@@@@....@.@@.@@@@@@.@@@@.@.@..@@@@@.@@@@@.@@@@@@@@@@@.@@@..@.@.@@@@ +@@@...@..@@@.@@..@@@.@.@@..@..@@@@@@@@@@@..@@@@@@.@@..@..@@@@@@@@@@@@@@@.@@@@.@@@..@@@@..@@@..@@@@@@@@.@...@@@.@....@.@@.@@....@@..@...@.@ +.@@.@@@...@@@@@.@.@@@..@@@@@@@@.@.@....@.@.@@@@@@@@..@@@.@.@.@@@@@@..@@@.@.@..@@@@@.@@@@.@..@@@..@@@@@@@.@@@..@..@@@@@@@.@.@@@@@@@.@@@.@@@ +.@@@..@@.@.@.@.@..@@.@@@.@@.@@.@.@@.@@@@.@@@.@@..@@@@..@@@@.@@.@.@@@.@....@@@@..@.@.@@.@@@@@.@..@@@@@@..@@@..@...@@.@@.@.@@.@.@@@@@@.@..@@ +@@@.@.@@.@@.@.@@.@@@.@@@@@.@@@.@@.@@@@@.@@@@.@.@@@@@@..@@@.@@@@@..@@@@@.@.@@@@@@...@@@@@@@@@@.@@@.@@.@.@@.@@@@@@@@@...@.@@@@@@@...@@@@@@@@ +@@@@@.@@......@@..@@@@...@@@@@@@@.@@@@@@@@@.@..@@@@@@@.@@..@.@@@@@.@@@@@.@...@@@......@@@@@.@@@.@..@@@..@@.@@@@@@@.@@...@@@@....@...@@@... +@@.@@.......@@@@@@.@@@@@.@@@...@@.@@@@@.@@.@.@@@@.@.@@.@@..@@@@...@.@.@@..@@@@@.@.@@@@@.@@@...@@@@.@..@@@..@@@.@.@.@@@@@@.@.@@@@@.@@.@.... +..@@@@@@@@@.@..@@@@@@@@@@.@@@.@.@.@@@...@@@...@.@@..@.@..@.@.@.@...@@..@@@@...@@.@@@.@@@@..@@@@@.@@.@@@@@@@@@@@@..@@.@@@.@@..@@.@@.......@ +.@.@@@@.@.@@@.@@@@@@.@.@.@@.@@@..@@..@@@..@.@@..@.@@@@@@@....@@.@@@@....@.@@@....@@..@@@@.@@@.@@@@..@@.@.@@@..@.@@.@@@@@@.@.@@@.@.@.@...@. +@@@@.@@.@@...@.@..@...@.@@@...@@@@.@@@@@.@@@@@@@@@@@@@.@.@@@.@@...@.@.@..@..@@@.@@@@.@..@@@@@@.@@@.@.@@..@@@@@.@@...@@@@.@.@@@@@@@.@..@@@@ +.......@@@@..@.@..@@@@@@@..@@@@@.@@@..@.@@.@@@@@@@@@@@@@@@@@.@.@.@@.@..@@@@@..@.@@@@@@@@@@@@@@@@@@.@@@@...@@@@@@.@.@.@@@@@..@@@@@.@.@.@@@@ +@.@..@@@.@@@@.@@@@.@..@@@@...@@..@@@@@@@@@@@@@..@@@..@@@@@@.@@@@@..@....@@.@@@.@..@.@@@...@.@@.@@@@@.@.@@.@.@@@.@@@@@@@@.@.@.@..@@.@@@@.@@ +@.@@@@@@.@@.@@@.@.@@@@..@@@.@@@@..@@@@@@@@.@@@@@...@..@@@@@@@.@@.@@.@@..@..@@@@@@@@@.@@.@@@@@.@@.@@@@@..@.@@@.@@@@@..@@...@@@@@.@@@.@@@... +@.@@@@@..@.@@@@@.@@@@@@@..@..@@@.@@@.@@..@@.....@......@@@@.@@@@.@.@..@@..@@.@@.@@@@..@..@@@@@....@@@@@...@.@@@@@....@@@@@@@@@@..@@.@@.@@. +@...@@@@@.@@@@.@@...@@@@@@@@..@..@@.@@.@@@..@.@@@.@@@@.@@....@......@@@..@.@.@@@@.@.@@@@.@@@@@@.@@..@@@.@@@.@@.@@@.@@@.@@@@.@@@@...@@@..@@ +@@@..@@@@@@@.@@.@@@@.@@@@.@@@@@.@@@.@@.@@..@.@@@..@@@..@.@@.@@@.@@@..@...@..@@@@..@..@@@@.@..@@@@.@@@.@@.@@.@@@@@.@@.@.@.@..@@@@.@.@@@.@@@ +@@.@.@@...@..@...@@.@@@...@@@@@@@@@@.@.@@@.@@@@.@.@@.@@.@@@@.@@@..@..@@@...@@.@@@.@@@@@.@.@@.@.@@@@..@@...@@@@@@.@@..@@....@@@@@...@..@.@@ +.@@@@@@.@..@.@@.@.@..@@@.@@@@@..@..@.@.@@@@.@..@@..@@@@@.@@.@@@@@@@@.@..@@@@@@@@@@.@@@@@@@.@..@.@@@@@@@..@..@@@@@@@..@.@@@.@@.@..@.@.@@@@@ +@.@@@..@@@.@@@@@@@@@..@.@@.@@.@@.@@@@.@@@@@@@@@@...@@@@@@@.....@@.@.@@.@@@@@@@..@....@@..@@@@@@@.@@...@.@....@@@..@@@@@@@@.@@..@@.@@@@@.@@ +@.....@@.@@@.@@@...@..@@@@....@@@@@..@.@@..@.@@@@@...@@.@.@@@@.@@..@@.@@@@@..@@.@...@.@@.@.@.@@.@@@.@@@@@@.@@@@@@.@@@@.@@@@@@@@.@@.@.@@@@@ +.@@@.@@.@.@....@@@@@@.@@@@@@.@@@@@.@.@...@@.@@@@@@@.@...@@@@@@.@@@.@@..@@@@..@@@@..@@.@@@.@...@@.@@@@..@@.@@@@@..@@...@@@@.@@..@@@@.@@@@.@ +.@@@.@....@@@..@.@@.@.@@@.@@@@@@@..@.@.@@@@@.@@@@@..@@.@@@@@@@@@@@@@@@@@@@@@.@@@@.@@...@......@.@@@@@@..@.@.@.@@@.@@@.@@@@.@@..@.@@@@@.@@@ +@...@.@@..@.@.@@@.@@....@.@@@.@@@@@@@@.@.@.@@@@.@@@@.@.@@.@@@@.@@@.@@@@.@.@...@.@@@.@@....@@..@@@.@@@@@.@@@.@.@@@.@@@.@@@@@..@....@.@.@@@@ +.@@@..@@.@...@@@@....@@@@.@@.@@.@.@@@@.@.@@.@@@@.@..@@.@@@...@@.@@@.@@@@@.@..@@@@.@...@@@..@@.@@@.@@.@@@@@..@@@@@@..@@@@.@.@.@@@@@.@@@@@.@ +.@.@@@...@@.@.@@@.@@@@.@..@.@@@@@.@@@@@@.@.@@@@.@....@.@@@@.@...@..@.@..@@@.@@@@@@.@.@..@@@.@.@@@@@..@@..@@@@@@@@@@@@.@@@.@@@.@@@.@@@@@..@ +.@@@@@@@@@.@.@@@.@@@@@@@.@@@@@@.@@@.@@..@@@@.@@..@.@@...@@.@@@@@@@@@@...@..@.@@@..@@@@@@@.@@@.....@@...@....@@@@@@@@.@@.@@....@...@@..@@@@ +@@@@@.@@@@@@@@@@@.@@.@.@@....@@.@@.@.@@.@.@@@@@@@@@.@@.@@@..@@@.@.@@@@@.@.@@..@@@@.@@.@@@@.@.@.@.@@@@@...@@.@@@.@@@@@@@.@.@.@@@@@@@...@@@@ +@@..@@.@....@@@@@....@..@@@@@.@.@@..@@@.@.@@@@.@@@@@..@@.@..@@@.@@@..@.@@.@@.@.@@@@@..@@@@@.@@...@@...@@@@@@@.@.@@@....@...@@@.@..@@@@@... +@@@@..@.@@@@.@...@@@@@..@@@@@@....@@@@.@@.@..@.@@@@@@@.@.@@@@..@@@@@@@..@.@@@@@@@.@@@@@@@.@@.@@@@.@@...@.....@.@..@@@@@@.@@@@..@@@@..@@@@@ +@@@@@@@@@@@@@..@@.@@@@.@@@..@@@@@.@.@.@@@@@@...@.@.@@.@@@@.@@@@..@@@@.@.@@@@@.@..@@@@...@@@@@@@@.@@.@@@.@.@..@..@@.@@@@@@@@@.@.@@.@.@@@@@. +@.@@@@@.@@@@@@@..@.@@.@@@@.@.@.@...@@@@@@.@@.@..@@@@@@@@@@.@@..@@@@...@@.@.@@@..@@@@.@@@@.@.@@@@@@.@@@@..@@.@.@@.@@..@@@.@.@@..@@@@.@.@... +@..@@@@.@@@.@@@@@@@.@.@@@@@@@...@.@@...@@@@@..@.@@@..@@@@@@.@.@@@.@@@@.@..@@.@@@@..@.@@...@..@@@.@@@@@.@@@.@.@@.@...@..@@@@@@@.@.@.@@.@@.@ +@.@.@..@@@@@@@@.@@@@.@@@..@@@@@@.@@.@@@@@@@@.@.@@@..@@@@@@.@.@@@..@.@.@@@@@..@.@@..@@@..@..@@@@@.@@@.@@@@..@@@..@.@.@@@@@@@@@@@@.@@@@@@@@@ +@..@@@@@.@@.@@@.@@..@@@.@.@@.@.@@..@@@@@@@.@@...@.@@..@....@@@@@@@..@.@@@@@..@@@@@.@@@@@@..@@..@@@.@@.@@@@@.@@.@@@@@.@.@.@@.@.@@@.@@@@@@@. +@@@@@@..@..@@@.@@@@@...@..@.@@.@..@.@@@@@.@@.@@@@@.@@@@.@@....@@...@...@.@@..@.@@@@@@..@.@@@@@@@@.@@..@@@.@@..@.@.@@..@@..@@.@@@.....@@@.@ +@@..@.@@..@.@@@.@@@@.@@@.@@@@@@.@.@@@@...@@@..@@@@.@@@@@@.@@....@.@@@@@.@@@@.@@@@@@.@@.@@@@@@..@..@.@@@@@@....@@.@.@@@@@@@@..@@..@@@@.@@.. +..@.@@@@@@.@.@@.@@...@@.@@@@.@.@@@.@@.@.@@@@@...@.@.@@.@@.@@@.@@.@@.@@@.@@...@@@@@.@@@.@.@@@.@@@.@@@@@.@@.@@@.@.@.@@.@@@.@@@@.@@..@@.@@.@@ +@@@@@.@@.@.@@@@.@@@@@@..@...@@@@@.@@@@@@@@@@.@.@@.@@@...@..@...@@@@@.@@.@@@.@@@@.@@..@..@@@..@..@@@@@.@.@..@@@.@@@@@@.@@.@..@@..@@...@@@.@ +.@...@@@@@@.@@@@@.@@@.@@@.@....@.@@@.@.@@@@@@..@@@.@..@.@@@@@.@@@@@@.@@@@@..@..@...@@@@@.@@@...@..@@.@.@@@@@@.@.@.@@@@.@.@.@.@@...@@@.@@@@ +@.@@@@.@@..@@@...@@.@@..@@@@@@@@@@.@.@....@...@@@..@@....@.@.@.@@@.@@@@@....@@@@@@@.@@.@@@@.@@@@..@@..@@@..@@..@..@@.@.@..@.@@@@@@@.@@@@.@ +..@@..@@@@@.@..@..@@.@@@.@@...@@@@@@.@@@.....@.@@@@@@..@..@@@@.@.@@@@.@...@.@..@@@@@@@@@..@.@.@...@@.@.@.@@@@.@@.@@.@@.@.@@@@...@@.@@@@@.. +@@@@@.@.@.@@..@@@@@@.@@....@.@@.@@@@.@@.@..@@.@@.@@@..@@@@@....@.@@..@.@.@@.@@.@@@@@.@@@@@.@@@@@@.@@@.@@.@@.@@@.@@@@@.@...@@@@.@@@..@@.... +.@@@@..@..@@@@@@@@.@..@@.@..@@...@..@@@.@.@@.@@...@@..@.....@@...@@@@...@@@@@@@@@.@@.@@@@.@@@..@.@.@..@@.@..@..@..@.@.@@@@.@@@@.@@@@@@.@@@ +@@@@@@@@@.@.@@.@.@...@@.@@@@.@.@..@@.@@..@@@@.@..@@.@@..@.@.....@@@..@@@@.@.@..@.@..@@@@..@@@@@@.@.@@..@.@.@.@@.@..@.@@@.@.@..@@@@..@@@@@@ +@.@@...@@@..@@.@..@.......@@@@@@@@.@@@.@@@@@..@@@.@@@@.@@@@@@.@@@.@@@@.@@@@....@@..@@.@@@@.@@@.@.@@...@@@....@@@..@.@@...@@@@..@@@.@@.@..@ +.@.@@..@@@@...@@.@@.@@@.@@.@@@@@.....@..@@.@@@@...@@@@@@@@.@@.@..@@@@@.@@@@@@@.@@@@@@@@@@@.@@@@..@@@..@@@.@@@@@.@@@@@@@@@@@.@@@.@@@.@...@. +@@@@@.@@@@...@@@@.@@@.@...@@.@.@@@@@@.@@@@@@@@.@@@@@.@.....@@..@@.@.@@.@@.@@@..@.@@@@..@.@..@.@@..@@@.@.@@@..@@.@@@..@.@@@@..@..@@.@.@.@@@ +.@....@.@.@@@.@@@.@@@.@@@@.@.@..@@@...@@.....@@@.@@..@@..@@@@@..@@@@@@@@.@@@.@@@@.@.@@..@...@@@.@.@..@@.....@@@@@.@.@.@@@..@..@@@.@@@@@@@. +@@@@@@@@@.@@@@@@@.@@@@@@@@@.@.@.@@@..@@.@.@...@@@@..@@@.@@.@@@@@.@@@@@..@@@@.@.@.@@.@@.@@@@@@@@.@@@.@@@@@@@@.@.@@.@@@@@@@..@@@@.@@.@@@@.@@ +@@@@@.@@@@@@.@.@@.@@@..@@@@@@@.@@@.@..@@@.@.@@....@@@@@@@@@@@...@@....@@.@@@@@....@@.@@@.@..@.@@@@@.@@.@@@@@.@@@.@...@@.@@@@@@..@@@.@.@@@@ +@.@@@.@..@..@.@.@.@..@..@@.@@..@..@@@@@@@@@.@.@@@.@@..@.@...@.@.@.@@.@...@@@.@@..@@@@.@.@@.@@.@@@@..@@@@.@@@.@@@@...@@.@.@.@...@@.....@@@@ +...@@.@@.@@@.@@.@@@..@@.@@@@@.@.@@@@@..@@.@.@.@@.@..@@.@@@@@@@...@.@@@@.@@.@@@@@@@..@@...@@.@@@@.@@@.@.@@...@@@@@@..@@@@@.@.@....@..@.@.@@ +.@....@@@@@@@..@@@.@@.@@@@@.@.@.@@.@@@@@@@.@..@..@@@@@.@@@@@@@@@@.@@@@@@.@@.@.@@@.@@@@@@@@@@@@.@.@@.@.@@@.@.@@@@@@..@@.@@...@@@.@@@@@@@@@. +..@..@@.@.@.@@.@@@@@@@.@.@@@.@..@@@@.@.@@@@@..@@.@...@@.@@.@.@@@@..@@..@.@@..@@.@.@@@@.@@.@.@@..@@@.@@.......@@@@@@@@.@@@@@.@@@@@@@@@@.@@@ +@@@.@@@..@@@...@.@@.@@@@@@@@@.@@.@@@@@@@@.@@@.@@.@@@.@@@@.@.@.@..@@.@@@@@@@...@@@@.@@@..@.@@..@@@...@@.@@@.@.@.@.@.@@@@@@@@@@@@@@.@@@@@.@. +...@@@.@@.@@@.@@@...@@@@.@..@@@@@.@.@.@@@@.@@@@.@@@.@@@.@.@.@.@@@@.@@.@.@@@@.@.@@.@@.@@.@@.@@@@.@..@@.@@.@@@@.@@...@...@@@.@..@@.@@@@@@@@@ +@@@@@@@@@...@.@@@..@@.@.@@@@@@@@@.@@@.@@@@.@....@@.@@..@@@@@...@@@@.@@.@@@@@@@@@@@.@@@@@@@..@@..@@@@@@@.@@.@.....@@.@@@@@@@.@.@.@@@.@@@@@@ +...@@@@.@@@.@.@@..@@@@@@.@@@.@...@.@@@.@@@@@@..@@@.@..@.....@@.@@.@@..@@..@@@.@@.@@@@.@@@@.@.@@.@.@@..@.@@@.@@..@..@@@.@@@@@..@..@.@..@@.@ +@@@@@@@@..@@@..@.@@@.@@@@.@@@@@@@@@@@@@.@.@@@@@@.@@@..@@.@@..@@@@.@@..@.....@.@@@.@..@.@.@@@@.@@@@...@..@@@@@@@.@.@.@@..@@@.@..@@@.@@@.@.@ +@..@@.@@.@@..@@.@@@@@.@@.@@@....@.@@.@@.@@@..@..@@.@@@.@...@@@..@@@@@@..@@@.@@@.@@..@.@@@@...@@@@.@.@..@@@@@.@@.@@@.@@@@.@.@@@.@@@.@@.@.@. +.@@@.@...@.@@@@@@@@@@@@@@@.@@@@@@..@..@.@@@.@@@@@@....@.@@@..@@@@.@..@@@@@@@@.@.@.@@@@.@@..@.@@.@@@..@@@@@.@..@@...@@.@@.@@@.@@.@..@@.@@.. +@..@@@@@@@.@@@.@@@@@@@@@.@@@.@@@.@@@@@@@@@.@@...@@@..@@.@@@..@@@@@@@@@.@@.@@.@@.@@.@..@@@.@@.@@@@@@.@@@@@@..@@.@@@.@@@@.@@.@@@.@.@.@@.@@@@ +.@..@@@@@.@@@@@.@@.@@.@@@@.@@.@..@@@.@@.@@.@..@@.@@.@@@.@..@.@.@@...@@@@@@@@.@@...@.@@@@@.@@@@.@@@......@.@.@@.@@@@..@@@..@@...@@@@...@@.@ +@.@@@.@@..@.@@@@..@@.@@..@.@@@..@.@@@..@@@@@@@@@@@@....@.@@@@@.@@@@@.@@@.@...@@@@@@.@@@.@.@@@@@@@@@@..@@.@@@@@@@@@@.@@@@@@@.@.@@@@.@@@@..@ +@@.@.@.@@@@@.@@@@@..@.@@@@@.@@@.@.@@@@.@@@@@.@@.@.@..@@@@@...@.@@@.@@..@@@@.@@@.@@@.@@@@@@@@..@..@@@@@.@@...@@@@.@@@@@@@@.@...@.@@..@.@@@@ +@.@@@@@@@@@.@@@@@@..@@@@@@.@@@@@@....@@@@@..@.@..@...@.@@@.@@@.@...@@.@@@@..@@@@@@..@@@@.@..@@@..@@@.@@@..@@.@@.@@@@@..@@..@.@@.@@@@@@.@@. +@....@@@@@@.@@.@@@@@@.@@@.@.@@@@@...@@@@.@@@@@@.@@@..@@@@@@@@@@@@..@@@..@@.@@@@..@@.@@@..@.@@@...@@@@..@.@@@@..@@.@@@.@@@.@@.@@@@@@@@@@.@@ +@.@.@.@.@.@@@@@.@@@..@.@..@@@.@..@@@.@@@@.@@@..@@..@.@@@@@@@@@@.@@@.@@@@.@@@.@@@@@@@@@@..@......@..@@@@..@@@.@@@.@...@@.@@..@@@@@@@@@.@@.. +.@..@@@@.@@..@@@@@...@@@@..@@.@..@@@@@@@.@.@.@@.@@@@@@@@.@.@@..@.@@@@@@@@@@@@.@@.@.@@@..@.@.@@@@.@@@@.@@@@@@@@.@..@@@@@@.@..@@.@.@..@.@.@@ +@@@@@@@.@.@@@.@@@@..@@.@.@@@..@@.@.@.@@@@@@@@..@@@.@.@.@@@.@@@@@.@@.@@.@@.@@@@..@..@.@.@@@..@@@@@..@@@@.@.@@..@@..@@@.@@@..@@@@@@@@@@@.@@@ +.@@.@.@.@@.@@.@@@@..@@@@@@.@..@@@@.@.@..@..@@@@@.@@.@@@@...@@@@@@@@@@@@@.@@@.@..@@@.@@.@.@@@@.@@.@.@@@@.@@@.@@@@....@@@@.@.@....@@@@.@...@ +@@..@.@@@@@@.@@@@@@@.@@@@..@@@@@@.....@@.@.@@@@.@@@@@.@@@@...@.@@@@@@.@@@.@@@@@@@@..@@@@.@@@..@@@....@..@@@..@@.@@@.@@.@.@@...@@@@@.@@@@@@ +@@@@@@@@.@@.@..@.@..@........@@.@.@@@.@@@@@.@@@@@@@@@.@@@@@.@@@@.@@@@@@@@.@.@@@.@...@.@.@.@@@.@.@.@@@@@@.@...@.@@...@@@@@.@@@@...@@.@@.@@@ +@.@@..@.@.@@....@@@@@..@..@@@@.@@@@@@@@.@...@..@@@@@@.@@@.@@@@@@@@@.@@@.@@@@@@@.@@..@..@.@@..@@.@@@@@@@..@.@@@...@@@@.@.@@.@@.@@@@@.@.@.@@ +..@@@.@@@@.@@....@@@....@@@@@....@.@@@@..@@..@@@@@@..@.@..@.@@@@@....@@.@@.@@@.@@@@.@@@@@@..@@.@@@@..@@@.@@.@@@@...@..@@@@@.@..@@@@@@@@.@. +@...@..@@.@@.@@.@.@@..@.@@@@@@..@@@.@@@@..@@@@@.@@@@@.@.@.@.@@@@@@@@.@@@@..@@@@.@@..@.@@@@@@@@.@@@..@@.@.@@@@..@.@@@@.@@@@@@@.@..@@@..@@.@ +@.@@.@@@@..@.@@@@@@....@@@..@@@@@@.@@@.@@.@@.@@.@....@@@.@.@@@.@@@..@@@..@@@.@@@@@.@@@..@.@@.@@@..@.@@@.@@.@@@.@.@@.@@....@@.@@@.@@.@@@.@. +.@@.@@@.@.@@@@@@.@@@@.....@.@@@.@.@@@@@@@@@@@@@@.@@.@@@@@@.@@....@.@@@.@.@@.@@.@..@@@@...@@@@@.@@..@@.@@@@..@@@@.@.@@...@@@@@@@.@.@@@@@... +@.@@.@@..@@.@.@@@@..@@@@@@.@.@.@@@...@@@@@@.@@.@@@@.@@@.@..@..@.....@@@@.@@@@.@@.@@@.@.@@.@.@.@@@@@@.@@.@@@.@.@@@@@..@.@@@.@....@.@@@..@@@ +.@.@@@@@@@@@...@..@@@@@@.@@.@@.@@@.@@@...@...@@..@.@@.@.@..@.@.@@@@.@@@@@....@@@@..@@.@@@.@@@@@..@@@..@.@@@.@@@..@@..@.@@..@@@@.@@.@@.@@@@ +.@.@.@.@@.@@@@@.@.@..@@@.......@.@@@@@@@@.@@.@@@@@@@@..@@@.@@@@@@@@@@@....@@.@@.@@@...@@....@@@@.@..@.@@@@.@@...@.@@@.@@.@.@.@@@@..@.@@@.. +@.@@@@@.@@@@@@..@.@.....@..@@@@@@@@.@@@.@@.@@@.@@.@.@@.@@@.@@@.@.@@@@@@@@@@@.@.@@.@@@@.@@.@@@.@@.@@....@.@@.@@@@@@@..@@.@.@.@@@..@@.@@@.@. +@@@.@@..@@.@@@@@.@@.@@@@@...@@.@@@.@@@@@.@@@.@.@.@@@@.@@@.@@@..@@@@..@@.@@.@.@@@@@.@..@@.@@@@@@@@@.@@..@.@@@.@@.@@@@@.@.@@@@.@..@@@..@.@@@ +@@.@@@@@.@...@@@@.@..@.@@@@@@@@@.@...@@@@@..@.@...@@@@@@.@@@.@@@..@@@@@@.@@.@@@@@.@@@.@@@@.@@.@@@@@.@@@@@@@.@..@@.@..@..@@@@@@@@.@..@@@... +@@@.@@@.@@@..@@@@@@@@.@@@@@@@@@@..@@@@.@..@@@.@@@@@@.@@@@..@@.@..@@@@.@@@.@..@@@.@@@.@@@..@@@@@.@@@@.@.@..@@.@@@@@@@@@@@@@@..@@@.@..@@@..@ +.@.@....@@.@.@.@.@..@.@@@@.@@....@.@@.@@@...@@@@.@@@@.@@@.@@@.@..@@.@...@@.@@@@..@@@.@..@.@..@..@@@@@..@@@..@@...@..@@@@@@.@.@@.@@@@..@.@@ +@@@.@.@.@@@.@@@.@.@..@.@@@@@.@.@@.@.@@@@@@@.@..@@@@.@@@.@@@...@@@@@@@.@@@@@@@@@@@@@.@@@@@.@.@@.@@..@@@@@@@.@@@...@@.@@..@..@@..@.@@@@@@..@ +.@@..@...@@@@@@@.@.@.@@@@@..@.@.@.@@.@@.@@.@@@.@.@..@@@..@..@.@..@@@@@@@...@.@.@.@@@@@..@.@@@.@.@@.@..@@@..@@@@@@@@@@@@@.@@.@@.@@@@@@@@@@. +.@@@@@.@@.@@@.@@@@@@.@.@@.@@@@..@..@@.@..@@.@@@@.@..@@@@@@@...@@@@@@.@@@@@@@@@....@@@@@@@@@.@.@@@@...@@@@.....@@..@@.@@.@.@@@.@@@@.@@.@@@@ +@@.@@@@@.@.@.@@@@@.@.@..@@@@.@..@@.@.@@@@@@@@@@@.@.@@....@@@@.@.@@.@@.@@@.@..@@@@@@.@@.@@....@@..@...@@@..@@@..@.@.@..@..@@@@.@@@@..@..@@@ +@..@@.@@.@@.@@@.@@@.@@@@@.@..@.@.@@.@.@@@@@@@.@.@.@@@@@@@@@.@@@@..@.@.@@@..@@@@@@@@@@.@@@@.@@.@@.@@..@@@@...@.@@..@@@@.@.@@@.@@@.@.@@@.@@. +@@@@.@@.@.@@..@@..@.@@@.@.@.@...@@..@.@.@..@.@.@@@@@@@@.@.@@@@@@@.@@@@.@@@@.@..@.@@@...@.@.@@@@@.@@@@..@@@@@@@@@.@@@@..@@@@@.@...@@@.@@.@@ +@.@@.@@@@..@@.@.@@@.@.@...@.@..@@@.@@@@@@@@..@@@.@@..@@....@@@..@@@@@@..@@@@.@@..@.....@@@@@@..@@..@.@@@.@@@@..@.@@@@.@@@@@.@@@...@.@.@@@. +@.@@@...@@@.@@..@@@@.@@@@@.@@@@.....@@@@@@@.@.@@@@@@.@@@@@..@@@.@@.@@.@@.@.@..@@..@@.@.@@.@.@.@@@@@@@@....@@..@...@@..@@@.@@.@@...@.@@.@.@ +@@@@@@@..@@@@@.@@@@@.@@.@.@@...@@@@@@@@@.@@.@.@@@@@@@@@@@@.@.@@.@.@@@@@@.@@@.@.@.@@@..@@.@...@@@.@..@@@@@@@.@@@.@@@.@.@@.@.@.@.@...@...@@@ +@@.@@@.@@@@.@....@...@@@.@..@@@.@@...@.@@@@@@@@..@@@.@@@.@@.......@@..@.@@.@@..@@.@@.@@@@....@.@@.@.@@.@@@@@@@@.@.@..@@.@@.@..@@@@@@@@@@@@ +.@.@@@...@@@@@@@@@@.@@@...@@@.@@@@@@.@.@@@.@.@@@@@.@@..@@@@..@.@@@.@@@@.@@@@.@@@.@.@@@..@..@@..@.@.@@@.@@@..@@@@@..@.@@.@@@.@.@....@@.@@@@ +@.@@.@@....@@@.@@@@.@@@@.@..@.@@@@@@@.@.@@.@..@.@@.@@@.@@@.@@.@.@@.@.@@@@@@@..@.@@@.@@..@@@@@@@@.@@@.@@..@@@.@@@@@@..@.@@@@@@@..@...@@...@ +.@@.@..@...@@@@@@@@@.@...@.@.@@@.@@@@.@@.@@@@@@@.@@@@@@.@@@@@.@@.@@....@.@@.@@.@@@.@@.@@....@@@@@.@@@...@@@@@.@@@@@@@.@.@@@.@@@@.@.@.@.@.@ +@@..@@.@@...@@..@@@@@@@@@.@@@.@@@..@@@@@.@@..@@@@@@@..@@.@@@....@.@@@@.@....@@@..@.@.@.@@@@@@@@.@..@.@@..@@@@..@@.....@@.@@@.@@..@.@.@.@@@ +@.@.@..@.@@@.@@@@@@.@..@@.@.@.@@@@.@@@.@@.@.@@.@.@.@@@..@.@@@@@@..@@.@@@@@@@@@@......@.@.@...@@.@@@@@.@@..@@@@@@.@.@@@...@@@@@@.@@@@@@@@.@ +@@@@.@@@.@@.@@@@@@.@.@@@.@@.@@@@@@@@@@@..@@@@@@...@@@@@@@.@.@@.@.@.@.@@@@.@@@@@....@@.@@@..@@@.@@@@@...@@@.@@@....@..@@@@@@..@...@@@..@@.@ +@.@@..@.@@@@@@.@@@.@.@....@..@.@@@@@@.@@@@@@@@@@...@@.@......@@..@@@@.@@@@@.@@@@...@@.@.@.@@.@@.@@@@@@.@@..@.@@@...@@@.@@.@@@@.@@@@@@@.@@@ +@..@@@.@@.@@@@...@@@@@..@@@.@@.@@@@.@..@@@@.@@.@@.@..@@@@@@@.@@@.@.@.@.@@.@@@.@@@.@@@.@..@@@.@..@@.@@@@@..@@@@.@.@@@@.@@@..@@@@@@@.@@.@@@@ +@..@.@@@..@@@@@@@@@.@@@@@..@@@@@@@.@@.@...@.@..@@@@.@@@@..@@@@.@@.@@.@...@.@.@@.@@.@.@@@...@.@..@@.@@..@@@@@.@.@@@...@@@..@@..@..@@...@.@. +@..@.@.@@.@@@@@@.@@@@@..@..@.@@@@@..@.@@@.@@@.@@.@@@@@.@@@@@@@@.@@..@.@@@@.@@@@@@.@@@..@@@@....@...@.@@@@@@.@..@@@.@@@@@...@@@.@@.@@.@@@@@ +..@@@.@@..@@@@@@@.@@@@...@.@.@@..@@@.@@.@@@..@.@.@.@@@@@@@@@@@.@@@...@.@@.@@.@.@@@...@@@@.@@@@.@..@..@..@@@...@.@@@@@..@@@...@.@.@@.@@@..@ +.@@@.@@@@@@@@.@.@@.@@.....@.@@@@@@@@@.@..@@...@@....@@@...@...@@@@.@@@...@...@..@@@@.@.@@.@@@@@@@@@@@@@@@@@.@@@@@.@@@@@@@@@@@@@@@@@@.@@@@@ +.@...@.@@..@..@@@...@.@@@@@@@@@.@@@.@@@.@@@..@@.@@...@@.@@@@@.@@..@..@.@@.@@..@@..@@@@@@.@@@@.@.@.@..@..@@@@.@@@@@@@@.@@@@@...@.@@..@@@.@@ +@@@@@@@..@@@.@@@@..@...@....@@.@.@.@@.@..@.@@@.@@@@@.@.@@@@@@@...@@.@@@@@..@.@.@..@@@@.@@@@..@@...@@@.@@.@.@.@.@.@@@@@..@.@.@@@@@.@@.@@.@. +@@.@@@@.@..@@..@@@@@@..@@@@@@@..@@..@..@@.@@@@@@..@@@@.@.@.@@@@@@@@..@.@@..@@@@@@@.@@@@.@....@.@@@@..@@.@.@.@@@@..@@..@...@..@@@@..@.@@@@. +@.@@@@.@...@@..@@@@.@@@..@.@@@.@@@@@@@@@@.@@@@@@@@.@@@..@@@@@@.@.@@.@@..@@.@@...@@.@@@@@@@@.@@@@@..@@@@.@..@.@@@@.@@@@@..@@@.@@@@.@@@.@@.@ +@@@.@@..@@@.@@@@.@..@@@@.@@@@@@@.@.@.......@@@@@@.@@@@@.@.@@.@@@@..@@@@.@@..@@.@.@...@..@.@@@.....@@.@@@@.@..@...@@@...@@@@@..@.@.@@@@@@.@ +.@.@.@@.@.@.@@..@..@@@@@@@@@.@@@.@@@@.@@...@@@@@..@.@@@@.@.@@.@@@@@@@@.@@.@@.@@@@.@@@@..@.@.@@@.@@.@.@.@@@@@@@@.@@...@@..@@@.@.@@@@@.@@@@. +@@@@@@..@@@.@@@@@.@@@.@.@@..@@@.@@@@..@.@@.@@......@@.@@@.@.@@@.@..@@@..@@@@.@@.@@@@..@@..@@.@@@...@@@@@@.@@@.@@.@@@@@@@@@.@@@@@@.@@@@@@.@ +@.@@.@@@@@@@@@@@@@@.@@@@.@@@@@.@.@.@@@@@@@.@@@@....@@..@..@.@@@@@@@@@..@..@@..@..@@@@.@@.@@@@.@.@.@@....@@.@@@@.@.@@@@..@@@@..@@@.@@..@@@@ +@@@@@@@@@@@@@@@@.@@@@.@@..@.@@@.@@@.@.@@@@@..@@@@@@..@@@@..@...@@...@@@@.@.@@...@.@@@@......@@.@@@@@..@.@@@@@.@@..@@@.....@@@@..@.@.@..@@@ +....@.@@@@@@.@@@@.@@@....@@@@@...@@@..@@..@@.@@@@.@..@@@.@@@.@.@@@..@@@.@@..@....@.@@@@@@@@@..@@@@@.@@@@@@....@@@..@@@@@@@@@...@@...@@@@.. +@.@@.@@@@.@@@.@@@..@@.@@@@..@@@.@....@@@@@@@@@@@@@.@@.@@@.@..@@@@@@..@@.@.@@@.@@@.@@.@.@.@.@@.@@@@.@@@.@.@@@@@.@.@@.@@.@.@@.@@.@.@@@.@...@ +.@@.@.@@@@.@@...@@@@@@@@@.....@@@@@@@.@@@..@@@......@..@.@@@.@@...@@@..@..@..@@@@@..@@@.@@..@.@@.@.@..@.@@@@.@..@@.@@@@@@..@@@.@@@.@@@@@.@ +@@.@@.@@..@@@@@.@@@@@@.@@.@.@.@@@.@@@@@@@@@@@@@@@@..@@@@@.@@.@.@@.@.@@..@@@.@@..@..@@.@..@@@@@@@@@.@@@@@@@@...@@@@@@..@@..@@@@@@@@@.@@@@@@ +@..@@.@.@@@..@..@.@@@@@.@@@@@@.@@@@@.@.@@.@.@@@.@@@@@.@.@@@@@@@.@.@@@@@@@@@@.@@.@@@@@.@@.@@@@.@@@@@.@@@@.@..@...@..@@@@@@..@...@.@@@@.@@.@ diff --git a/2025/04/part1.py b/2025/04/part1.py new file mode 100644 index 0000000..3bfcae1 --- /dev/null +++ b/2025/04/part1.py @@ -0,0 +1,46 @@ +import numpy as np + +def read_map(filename: str): + # Read file as list of strings + with open(filename, "r") as fp: + data = fp.read().splitlines() + + # Use Numpy to make it a 2D array of characters + tp_str_map = np.array(data, dtype=str)\ + .view("U1")\ + .reshape((len(data), -1)) + + # Make it a boolean map + tp_map = np.zeros_like(tp_str_map, dtype=bool) + tp_map[tp_str_map == "@"] = True + return tp_map + +def print_map(tp_map): + view = np.zeros_like(tp_map, dtype="U1") + view[tp_map] = "@" + view[~tp_map] = "." + for i in range(view.shape[0]): + for j in range(view.shape[1]): + print(view[i,j], end="") + print() + +def count_neighbours(tp_map): + delta1D = np.array([-1, 0, 1]) + X, Y = np.meshgrid(delta1D, delta1D) + neighbour_counts = np.zeros_like(tp_map, dtype=int) + + for x, y in np.ndindex(tp_map.shape): + if not tp_map[x,y]: + continue + dX, dY = X.copy() + x, Y.copy() + y + legal_idx = (dX >= 0)*(dX < X.shape[0])*(dY >= 0)*(dY < Y.shape[1]) + neighbour_counts[x, y] = (tp_map[dX[legal_idx], dY[legal_idx]]).sum() + print(neighbour_counts) + max_rolls = 4 + print(neighbour_counts < max_rolls) + return (neighbour_counts < max_rolls).sum() + +if __name__ == "__main__": + test_map = read_map("testinput") + print(test_map) + print(count_neighbours(test_map)) diff --git a/2025/04/testinput b/2025/04/testinput new file mode 100644 index 0000000..8209399 --- /dev/null +++ b/2025/04/testinput @@ -0,0 +1,10 @@ +..@@.@@@@. +@@@.@.@.@@ +@@@@@.@.@@ +@.@@@@..@. +@@.@@@@.@@ +.@@@@@@@.@ +.@.@.@.@@@ +@.@@@.@@@@ +.@@@@@@@@. +@.@.@@@.@.