From 61a1686010fff82723bea69423b39ed73a06996e Mon Sep 17 00:00:00 2001 From: Oschly Date: Tue, 30 Dec 2025 12:55:57 +0100 Subject: [PATCH] Day 4, part 1 --- src/day4/input.txt | 139 ++++++++++++++++++++++++++++++++++++++ src/day4/mod.rs | 99 +++++++++++++++++++++++++++ src/day4/sample_input.txt | 10 +++ src/main.rs | 3 +- 4 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 src/day4/input.txt create mode 100644 src/day4/mod.rs create mode 100644 src/day4/sample_input.txt diff --git a/src/day4/input.txt b/src/day4/input.txt new file mode 100644 index 0000000..5aae821 --- /dev/null +++ b/src/day4/input.txt @@ -0,0 +1,139 @@ +@..@@.@..@@@.@@@@@@.@@@@@@@@.@@@.@@@.@.@@@.@....@@@.@...@@.@..@@@@@.@@@.@@...@@.@@@.@@@@.@@@@.@.@@@@..@@@@@@.@.@.@.@@@@.@@.@@.@@@@..@.@.@@@ +.@..@@@@@@@.@@@@.@@@@..@@.@.@..@@@.@@@@@@...@@.@@.@...@@@..@.@@@@......@@@@@@@.@@.@.@@@@..@....@.@..@@.@.@@@.@.@@@.@@@@.@@.@.@@..@@@@.@@.@@ +@@@..@@@@@@@@@@@.@..@.@@@@@@@@@....@.@.@@@@@.@....@@@@@@.@@@@@@@@@@@@@.@.@@...@@@@@..@@@@@.@..@@@@.@@@@.@@@@@@@@.@@@@@@@@@@@@@@@@.@@@@@@@.@ +@@@@@@@.@@@.@.@@@.........@.@@@.@@@@@@.@.@@@@@@@@..@@@.@@@@@@.@.@.@.@.@@@@@@@@.@@@@@@.@...@@@.@@.@@.@@@@@@@.@@.@.@.@@@@.@.@@@.@@@.@@.@.@@@. +..@@..@@@.@@@@@@@.@.@.@@.@@..@@...@@@@@.@@@@@.@@.@@@.@@.@@@@@.@@.......@@..@@..@.@@.@@.@@@.@.@@@@.@..@@@.@@@@@.@@....@@@@@@.@@@@.@@.@@@.@.@ +@@@@@@......@@@..@@.@@.@...@.@.@@@@.@.@.@...@@@@.@.@@@@@@@@@@@@...@....@@..@@.@@@@@@@@@..@@..@@@.@@@@@@@@@.@@@.@@@@@.@@@.@@@.@@@@@.@.@..... +.@@@@.@...@@@....@@...@@@@@@@@.@@....@.@.@.@@@@@@@@@@@.@@.....@@@@@@@@@@@.@.@@@@@@@@@@@@.@@@.@@@@@.@@@@@@@..@.@@....@@@..@@.@.@.@.@.@.@@@@. +@@.@@.@@@.@@@@.@..@...@.@@@.@.@@@@..@..@.@@@.@@@@.@...@@@@@@.@.@@@...@@.@@@@@@@@@..@.@@@..@@@@@@@@@@.@@@.@@@@@@...@.@@.@@@.@@...@@@.@.@.@@@ +....@.@..@@@@@.@@@@@@@@@@..@@..@@@@.@@.@.@.@@.@@@.@@.@@@@@@.@@@@@.@@.@@@@@..@@.@.@@@..@@@@.@@@@.@@@@..@@@@@@@@..@..@.@.@.@@@.@.@@@@..@@@@.@ +@@@.@@@@.@.@@@.@..@.@.@@..@@@.@.@.@@@@@@.@..@.@@.@...@@.@.@@...@@@...@@@.@@@@@..@.@@@.@@@@@@@@..@@@@@@@@.@@@@.@@@@@..@@.@@..@@.@@@@..@.@@.@ +@@@@.@@@.@..@@@@.@@....@....@@@@@@@@@@@@.@@@.@@@@@.@@.@..@@..@.@..@..@@..@@@@@..@@.@@@@@@@@@@@..@@@@@.@.@@@@@@@@@@@..@@@@..@@@.@@..@...@@@@ +@.@@@@..@@@@@.@......@@@@@@.@@@..@@@@..@@.@@@.@@@@@@.@@..@@.@@@@@@@@@@@@..@.@@@...@@@..@@.@.@@@@.@.@@@@.@.@..@@@.@..@@.@.@@@@@@.@@@@.@.@..@ +@@@@@.@..@@.@..@@@@@.@@..@@@@...@@.@.@.@.@..@..@@.@@@..@...@@..@@@.@.@@..@@.@@.@@.@@.@.@@.@@.@.@@.@.....@@.@@..@......@@@@@.@@.@@@@@@@.@.@@ +@@@@..@@@@.@.@......@@.@.@.@@..@.@@@@@...@@..@@..@@@@@@.@@@.@@..@..@@.@@@.@@@@.@@@@@@.@.@@.....@.@@@.@@@......@@@...@@..@@@..@.@@@.@@@@.@@@ +.@.@@@.@.@...@@@.@@.@@@@@@@...@@@@@...@@@.@@.@@@@..@@.@@..@@@..@@@.@@@@@@@@@..@...@@..@.@@@@@@@@@.@@@@..@.@@..@@.@@@.@.@@.@.@@@@@...@.@@.@@ +@.@.@@..@@.@.@@@@..@@@@.@.@@@@@@@@@@@..@@.@@.@@..@@..@.@@@@@@@.@..@@@@@.@@@@@.@@@@@@@@@@@..@.@@@@@@.@@@.@@@@.@@@@@@.@@@.@..@...@@@.@@@.@@.@ +@.@@@.@@...@.@@@@@..@@..@@@@@..@@@@@@..@...@@@@@@@@@@@@@@@.@..@.@@@@@@..@@@...@@.@@@@.@.@@.@.@..@@@....@.@@.@@@@@@..@.@.@..@@..@@@@@.@@@.@@ +.@@@@@@@.@@@..@......@@@@@@@@@@..@.@@.@@.@@@.@@.@@@@@@@.@@@@@.@@.@..@@@@@@@@..@@.@.@..@.@@@.@@@@@@@.@.@@.@@@....@@.@...@.@@@.@@@...@@@@@... +@.@@@@@.@@@@...@@@@@.@.@@@@.@@..@.@@@.@.@..@@@..@@@..@@@.@@.@@@@@.@@@@@@@@@@.@.@@@@..@@@.@..@.@@.@..@@@.@@@.@@@@@@@@.@@@..@.@.@...@@...@@@@ +@.@.@@.@..@..@@@@@.@@@@@@.@@@.@..@.@@.@.@@.@@.@.@@..@@@@@@@@@@.@@...@@.@@..@@@.@@@.@@@@...@@@@@@.@@.@@.@.@@@@@@.@.@@@@.@..@.@@@@@.@@.@@@.@@ +@@@....@@.@@@@@@@@@.@@@@@@@@@@@@@@.@@@@@@@@..@.@..@@@....@.@@@.@@@.@.@.@@.@@.@@@...@@@@@@@.@@@@..@.@@@...@@@@..@..@@@.@@@..@@..@@@..@@.@@@@ +..@.@..@@@@@@.@.@.@@.@@@@@@.@.@@..@@@@@@@@@@.@@@.@...@@@.....@@.@@.@.@.@@@@@@@.@..@.@@@@@@@.....@@..@@.@@@.@@@@...@.@.@@@.@@.@@@.@@.@@@..@@ +@@@@.@....@@@@@@@@@@.@@...@@@@.@@.@@@@.@.@@@.@@@@..@@@.@@@.@..@.@@.@@@@.@.@@@@@.@..@@.@@@@@.@.@@..@....@@@@@@@@@@@@@@@..@@@@.@..@@@@@@@.@@. +.@@....@@@...@.@..@....@@.@@@@..@..@@@..@@@@.@@@..@@.@@@.@..@@@..@@@@@@@...@@@@...@.@@.@@@@.@.@@@@@.@...@@.@@@@@....@..@@@@@....@@@@@.@.@@@ +@@.@@@.@@...@@.@.@..@@@..@@.@...@@@@..@@@.@..@....@@@..@@@.@@@@@@@@..@@@..@..@@.@@.@@@@....@@@..@..@@..@@@@.@.@.@@.@@@..@@.@..@@@@...@@@.@. +@.@.@@@@.@@@@@@@@..@@@@..@@..@@@.@@.@@@@@..@@@@@.@..@.@.@.@@@.@.@@.@.@.@@@.@@.@@@@@@@@..@@.@.@@@@@@@@@@.@@@@@@@.@@@@@.@@@@...@@@@@@@@..@@.@ +@@@..@@@@.@.@@.@@..@..@.@@@@.@.@..@@..@.@.@@@@@@..@.....@..@@@@@@@@@.@@..@.@@.@.@@@@@.@@@@@@@@@......@@.@...@@@@@..@@@@@@@.@.@..@@.@@@@@@@@ +@@..@@.@@@@@@@@.@@@@@.@@.@@..@@.@@.@@@@@@@@.@@.@.@@@...@@@@@@@@@.@@@.@@.@.@@.@@@@..@@@.@@@@@@@@...@@..@@@@@.@@@...@..@@..@@@..@.@@@@@@@.@.. +@.@@..@@.@@..@...@.@@@@@.@.@..@.@@@@.@.@.@@@.@.@.@@@..@@@@@@@@@@.@...@@@...@@..@@@.@@@@..@@@.@@@@@@@@@@..@@.@.@@.@..@......@...@@@.@@@@.@.@ +@@.@..@@.@.@@@.@....@@.@@@@@.@.@@@..@@@@.@@@.@....@.@@@..@@@@....@.@....@@.@.@@@@@@@@...@@@.@@@.@.@@@@..@@@@@@@@@..@@...@@@.@.@.@@@@.@.@@@@ +@@@@.@@@@...@@@@.@@@.@@@@@@@@@..@@@@..@@@....@@.@.@@@..@@.@...@@...@@.@@@@.@.@@@@.@@@@.@.@@@@@@@.@.@@...@@@@.@@@.@@@@.@.@@@.@.@@..@@@.@...@ +.@@.@@@@.@..@@@@@@@..@..@@@@@@.@..@...@@.@.@...@..@@@@@@.@@.@.@@@@@.@.@.@@..@.@@@@@@.@@..@@@.@@.@@@@@@.@@@@@@@@@@@@@@@@@@@@@.@@@@@.@...@@@. +@@..@..@..@@.@@@@@@@@@.@@@@@.@@@@.@@@@@@@..@..@@@.@@..@@.@...@@@@@..@@@@@.@..@@..@@@@@.@....@...@@@.@@@.@@@@@.@.@.@..@..@@@.@@@.@..@.@@@@@. +@@@..@@..@@@@@@@@.@@@..@@@@@@@@@@@@.@.@@.@.@@@@@..@.@@@@@.@@@@.@@@@@@@@@@@@..@@.@@@@..@@@.@@..@.@@@@.@@@@@@@@@@@@.@.@@.@..@.@.@@@..@.@.@@.. +...@@@.@@@@...@@.@.@@@@.@@..@.@..@@@.@@@@@..@@@..@@@@..@.@.@@@@@.@.@@@@@@@@@@.@@@.@@@@@@@@@.@.@.@@@@.@@..@@......@@..@@@.@@.@@.@@@@@.@.@@@@ +.@@@@...@....@@@...@@.@.@.@@@@@@@@@@.@.@..@@@@@@.@..@@@.@@@.@@.@@@@@@.@@...@.....@@@.@.@.@@@@@@..@@@@@@@@@.@@@.@...@..@@@@@.@@@...@@@.@@@.@ +@@@@.@@@...@@@.@@@@.@@@@@@@@.@@@@@....@@@@@@@@@.@.@@@@@@.@..@@@.@.@@@..@@@@@..@@.@@@@...@@@@@@....@@@@@.@@@@@@@@.@.@@@@@@@.@.@@@.@@.@.@@..@ +..@@..@@.@.@.@.....@.@@@@@@..@@@@.@@@@@.@@.@.@@@.@@@@@@@@.@@@@.@.@.@.@@@@@@@@@@...@@@@.@..@@@@@.@@.@@@.@@@@@@@@.@@@..@@@.@.....@.@..@@.@@.@ +@.@@@.@@@@@@.@@@@@@@@.@.@@@@.@..@.@@...@..@.@@..@..@.@.@@@..@@.@.@.....@@....@@@..@@@.@@.@@@@@@..@.@@..@@@.@@@@@@@@.@@@@@@@@@@.@@..@@@@@@@. +.@@@@@.@.@.@...@@@.@.@@@@@.@@@.@@@..@.@...@@@@@@@.@@@@@@@@@.@@....@@@@@.@@@@..@@@@@@.@.@.@..@.@.@.@@.@@.@@@@.@@.@.@@.@.@@.@.@..@..@@.@@.... +.@@@@@@....@.@@@@@@@@@@@@@@@..@@@@@.@.@.@.@@@@....@.@.@@.@@@@@@.@.@@@@@@@@..@..@@@..@@@.@@....@@@..@@@@...@@.@@@@@@.@.@@@@..@@@@@@.@...@.@@ +@@@@@@@@.@@@@@.@..@@...@@@..@@.@@..@..@@@@.@.@..@@@@@@.@.@@.@@.@@@@@.@@..@..@@@@@.@@@.@@..@@@@@@..@@@.@.@@@@@@..@..@@@..@.@@.@@@.@.@@..@..@ +@@.@@@@@.@@@@@@@@@@.@@.@..@@..@@@@...@@.@..@@....@@.@@.@.@@@..@.@@@@@@@@@@@@@@..@@@@@@@.@@.@@@@@..@.@@@@@@..@@@...@@@@@.@@@.@@.@.@...@@@@.. +....@@@.@.@@@@@@@@@.@.@@.@...@@@@@@.@.@..@@.@...@@@@.@@@@.@@@.@.@@..@@@@@@.@@@@..@@@@@@@@@@.@.@.@@..@.@.@@.@@@.@@@@@@@..@@.@@@@@.@.@@@.@... +@@@@@@..@.@@@@@@@@@@@@@@..@@...@@@@@@@@@@@.@.@@@.@@@@@..@.@@..@..@@@@@.@@@@@.@@..@.@@@....@@@@.@@@@@@@..@.@@@@@@@@@@@@@@@.@@.@.@.@@@@.@@@@. +@...@@..@.@@@@.@@@..@.@@.@@.@@@.@@.@..@@@..@.@@@@@@.@@@..@@@.@@@@.@@.@.@@....@.@...@@@@@@@.@@@.@@@@.@@.@@.@@.@@@@.@....@@@@@@@@@..@.@@@@.@. +@@@..@@.@.@...@...@.@..@.@@@@.@@@.@.@@@...@@@@@@@...@.....@@@.@@@@@@@@@@@..@.@...@@.@@@@.@@.@@.@..@@@@.@@@@.@@@@@.@..@@@..@@@.@@...@@..@@@@ +.@@@@@@@.@@@@.@@@@@.@@@.@@@@..@@@@@@@@@@@..@.@@@@..@@@@@@@@@..@@@.@@..@@@.@.@@@.@@@..@.@@@@@@@.@@@@@..@.@.@@@@@.@..@.@.@.@@....@@@@@@.@.@@@ +@@@@.@@.@@.@@@.@@@.@@@@@@.@@@.@@@@@@.@@.@@..@@@@@@...@.@@@.@..@@@@...@..@.@@@@@.@.@.@@@@@@@@@@..@@@.@.@@@.@@@@....@.@@..@@.@@@@@@@@@..@@@.@ +@.@.@@@@@.@@.@@@.@.@@@..@@.@@.@@@@@@@@..@@@@..@@...@.@.@@@....@.@..@@@@@@@@@@.@@....@.@@..@@@@@...@@@@@.@.@@@@..@@@.@..@@.@@.@.@@...@@@@@@@ +@@.@@@@.@@@...@@@..@.@.@@@.@@@@@.@@@.@.@.@.@@...@@.@.@@@@.@..@@..@@.@@.@.@.@..@..@@@@.@.@@@@@.@.@..@@@@@@@.@@.@@@....@.@..@@..@@...@@@.@.@@ +@@.@@.@@@@@@.@@.@..@..@...@@@.@@..@.@@@..@@.@.@.@@.@@@..@@@.@@..@@@@@@@..@.@@.@.@@@@.@.@.@@.@@@.@@@.@@.@@@@.@@@@@...@@@@@@@@@.@@@@@.@@..@.. +@.@@@.@@@@@@@.@.@.@@@@@.@@@@@.@@@@@@@.@@.@.@.@@@@@@@@@@@...@..@@.@@.@@@@.@@@.@@@@...@@@@@@.@@@@@@@.@@@.@@@@@....@..@@@.@@..@.@@..@..@@.@@@@ +@.@@@@@..@@@..@@@@...@@@.@@@...@@.@@..@..@@..@@.@@@..@@@@@@.@@@.@@...@.@.@..@.@@@@.@@..@.@@@@.@@.@@@@@.@@@@.@.@@.@.@@@@.@@.@.@..@...@@@@.@. +@@@..@.@.@......@..@...@...@.@@@@@@@@.@@.@@@.@@@.@..@.@@.@.@@.@.@@@.@.@@..@.@.@.@.@.@.@.@@@@@@@@.@.@@@@@@@@@@@@@@.@@@@@@@@..@@..@..@@@@@@.@ +@@@@.@..@.@.....@@.@@.@@.@@..@@@@...@.@@@@@@.@@..@@@.@....@.@@.@....@....@@@.@@@@@@@..@@.@@..@.@@@.@@@@@.@.@@@@@.@.@@@@...@.@@@@@@@@@@@.@@@ +.@.@..@.@@.@@@@@.@@@..@@@.@.@@@..@@@@@@@.@@@.@@.@@@..@@@@@.@.@.@@.@.@@@@.@..@@@.@@@...@@@@.@@@..@@.@....@.@@@@@..@@....@..@@@.@.@@.@.@.@@.@ +..@.@@@@@@.@@@.@@@.@@@@@@@@@@@@@@@...@@.....@@@@@@@.@..@@@@@@@@....@@@@..@@.@@@@@.@@.@.@@@@@.@.@@@@.@@@@@@...@@@.@.@.@.@@@@.@@@.@..@.@@...@ +@.@.@.@@.@@@@.@@@@@.@.@...@@@@..@@@@@...@..@@@@@@..@@.@@.@@@@...@@@@.@@@...@@.@@..@@.@.@@@@@@@@...@@@@@..@@.@.@@@.@@@..@@...@@@@@@@@@@.@@.@ +@@..@@.@.@@@@@@@.@@@@..@.@@.......@@..@@@@@.@@@@..@@@@..@.@.@.@@.@@@.@@@@@.@@@.@@@@@@@.@@@@@@@@.@@@@.@@.@.@@...@..@@@@.@.@@@@.@@..@@@..@@@@ +@@.....@.@.@@@@@.@@..@@@.@@@@.@..@@@@@...@@@.@.@@@.@.@@@@@@.@.@..@.@.@@.@.@@@@@@@@.@.@@@.@..@@.@.@..@.@@@@..@@@@@@@@..@@@@@...@@@@@.@@.@@@. +@@@@@@@@....@@@.@.@@.@@.@..@@@@@@......@@@.@.@.@..@@..@@@@@@@@@..@..@.@@.@@@@.@@@.@@..@@@@@@....@@.@....@@@@.@@@@.@@@@..@@@@@@@@@@@@@@@@..@ +@@..@@@..@.@@@.@..@@@@.@.@..@@.@..@..@@.@@@@@...@@..@.@@@@@@@...@@.@@@.@@@@@@@.@@@.@@..@.@@..@.@.@...@.....@@@@@.@.@@.@.@@@.@..@@@@@@..@@@@ +.@.@@@@.@....@@.@@......@@@@@@@..@@@@@@@.@.@...@@@@@@@@@@@.@..@@..@@..@@@@@.@@@..@@.@@@@@.@@.@@@.@@....@..@@@@@@@@..@.@@@..@@@@..@.@.....@@ +.@.@..@@.@.@@@@@@.@@@@@...@@...@@.@@.@@@@@@@@@@...@.@.@.@@...@.@@..@.@@@@@@@@.@@@@@@@...@@...@@@@@@@@@@@@@...@@.@@@...@@@.@@@@@@@.@@.@@..@@ +..@@.@@.@...@@@....@@....@@.@@@.@@..@..@@..@@@@.@.@@@@@.@@@@...@@@@@@@@@@.@.@...@.@@@@@.@@@@.@@@@@.@@@@@@.@@.@@@.@@@.@@@@@@..@@@@@@@@.@@@@. +@@@.@@@@@@@@..@..@@@.@@@.@@@.@@.@@..@..@.@..@....@@@@@..@@@..@.@@@@@@.@@.@@.@@@@...@.@@@@@.@.@@@@.@@@@@@@@@@.@@.@@@@@@@@.@@@@@@@@@.@@@..@.@ +@@@.@.@@.@@....@@@@@..@.@@@...@.@....@@@@@.@.@@@@@@@@@...@@...@.@@@@@..@..@@@.@@@.@@...@.@.@@@....@.@..@@...@...@@.@@@@..@.@@@@@@@.@..@@@.. +.@@@.@......@.@..@.@@....@.@@@.@@.@....@@..@.@@@.@@@@...@@.@@@@@.@@@..@@@@@@..@@.@.@@@.@...@@@@@.@..@@@@@@..@@..@.@@@.@..@@.@@.@@.@@.@.@@@@ +@@.@@@@@@..@@.@.@@@@@.@@@@@@@.@.@..@@@@@.@@@...@.@@@@@@@@..@@@.@@@@@@.@..@@@@@..@....@...@@@.@@.@.@@@@@@@@.@@@@@.@..@@.@@@@.@@@@.@@..@.@..@ +@.@..@@.@@@@.@.@@@@.@@@@@@@@.@@@@@.@@@@@@@@@@@.@@@@@@@.@@@@@@...@.@@@@.@@@@@...@@@@.@@..@@@@.@@.@..@..@@@.@.@@@@.@.......@@.@.@..@.@.@@@.@. +....@.@@@@@@@@@@.@@@.@..@@@.@@@@@.@@@@@..@@@@..@@@.@.@.@..@@.@@.@.@@@@@@.@.....@.@@@..@@@@@@@@..@@@@.@.@@@@@@..@@..@@@.@@.@@.@@@@.@.@@@@@@. +@@...@@.@.@@.@@@@@@@.@@@.@.@@..@.@@@@@.@.@...@@..@@@.@..@@@.@@@@@@@@@.@@@.@@@@@.@.@@@@@@.@.@@.@@@.@.@@@@..@@..@.@@@..@@@.@.@@@..@.@.@@@.@@@ +@..@@@.@@@@@.@@.@@@@@@@@@@@.@@@..@@@@@@@@@.@@.@.@@@@..@@..@@.@.@@@@.@.@@@.@@@.@@.@@@...@@@@@...@...@@@@@..@@...@@@.@@@@@@@@..@@.@@.@@@@@@@@ +.@.@.@@@..@@@.@@@.@@@@@@@@..@@@@@..@@@@@.@@@@@..@..@.@.@.@@@@@@@@@@@@@.@..@@@@@@@@@@.@.@.@@@@.@.@@@@@@@.@@@@@...@@...@@@@@@@@.@@.@@@@@@@@@@ +@@@@.@@@@.@@@@@.@..@@.@@@@@...@@...@.@..@..@.@.@.@@..@..@@@@.@@@@@.@..@@@@@@@@@@@.@@.@@@.@@@@.@@...@@@@@@@@..@@.@.@@.@@@.@..@@@@@@@@@@....@ +..@.@.@.@@....@@@@.@@@@@@@@.@@@@@.@@@@.@..@@@.@.@.@@.@@@@...@@@@..@.@...@@@@@@@@..@@@@@...@@...@.@..@@@@@.@@@@.@..@@.@@@@@@...@@.@@@.....@@ +@@@@@@.@@.@@@..@.@@@@@....@.@@@@@.@..@.@@@@@@..@@.@...@@..@@@@@@.@.@@.@.@.@@...@...@@@..@@@@@@.@.@@@@@..@@@.@.@@@@@@@..@@.@@@@.@.@.@.@.@..@ +@@@@@..@@.@@@..@@@....@@..@@@.@@...@.@@.@@@@..@@@@@@..@@@@@@@..@..@.@@.@.@..@@@@@@@...@.@@@.@@@@@@@@@@@@.@...@@.@.....@@@@.@.@@@@@@.@@@@@.@ +.@.@@@..@.@.@@.@.@..@@@@@@.@.@@@@@.@@@.@@@@@@@@.@.@.@.@@@@..@..@@@@@@.@...@.@@@@....@.@@@@@@.@..@@@.@@.@..@.@.@.@..@@@.@@@.@..@...@@@.@@@@@ +@@.@@@@@@@...@@.@.@@@.@@@@.@.@...@.@@@...@.@@@.@.@@..@@@@@.@@@@@@@@.@.@@..@.@...@@@@@...@@.@.@.@@@@...@@.@.@.@.@@@@@.@..@@..@.@..@@@..@..@@ +@@@@@@@@..@.@@@.@.@...@...@@..@@.@@@...@....@@@.@@@.@.@.@..@.@@@@.@@.@@@.@.@@.@@@@@@...@.@.@@@.@.@@@@@.@@@@@..@@@@..@..@@@@@..@...@@@@@@.@@ +.@@..@.@..@.@@.@@@@.@@@@.@@@@@.@.@@@@@.@@@...@.@@@.@@@....@..@@.@.@@@...@@@.@@...@.@@...@@..@..@@@.@@.@@@@@@@@..@.@@@@.@@@@@@..@@@.@@.@@@.@ +@@@.@@@@@..@.@@@.@@@....@.@...@.@..@@@.@@.@@@@@@.@.@..@@@@.@@.@.....@..@@.@.@@@@..@@@@@@@@..@@.@@.@.@@@@@.@..@@@@.@@.@@@@.@.@@@@@.@@.....@@ +@@@.@@@.@@@.@@@@@.@@..@@@@@.@.@@@@@@@.@.@.@@@@@@@@@@@@@.@@.@..@.@@.@@@@.@@@@.@@@@@@@..@@....@@.@.@@@@....@....@@.@@...@.@@@@.@.@@@@.@@@@@@@ +@@@.....@@@@.@@@..@.@@.@.@@@@...@@@@@@@.@@@@@@@.@@.@@..@@@@@@@...@@@..@@@@..@..@@@.@@@.@.@@@@@.@@.@@.@..@....@.@@@.@@@@@.@@.@@...@@@.@.@..@ +@@.@@.@@@....@.@@.@@.@@@@@@@@@@@@@..@..@..@@.@.@.@..@@.@@@@.@@.@@.@..@.@......@@.@..@@@.@@@.@@@.@@@@....@.@@@@.@@@@@@@..@@.@@@..@.@@..@...@ +@@.@@.@@@@@..@..@...@@@.@.@.@@.@...@.@.@@@@@@@.@@.@..@.@...@..@@@@@.@@@@@@.@@.@.@@@.@@.@@@@@.@@@@.@.@.@@@@@@@@@.@.@@@@.@@@.@.@@.@@@.@.@@@@@ +.@@@@.@@...@@@.@@.@@@@@.@@..@@.@.@@..@.@.@@@.@.@@@.@@.@.@.@..@@@.@.@@@@@@@..@@.@@.@@.....@@..@.@.@@@..@.@@@.@.@...@@@@@@@.@.@@@@.@@@@.@.@.. +.@..@@@@.@@.@.@@@..@@@.@@@@@@@@@@@.@@..@@..@@@@@.@.@.@.@..@.@.@.@@@@@@@@@@@@.@@@..@.@...@.@@@.@..@@@@@@.@@@.@@@...@@@.@@@..@.@@.@@.@.@@.@@. +@@@@@@@.@.@.@@@@@.@..@@@@@@@...@@@@@@@.@@.@@@@@..@@@.@@@.@.@@.@@..@@@@@@@@@@@.@..@@@@..@@@@@.@@@@@@...@@@.@@.@.@.@@@@....@@.@@...@@.@.@@@@@ +@@@.@@@@@@....@@..@@.@@@@@..@@@.@..@@.@@@@.@@.@@@@@@@@.@.@@.@@@.@@@@@...@@@@@@.@.@.@@.@@@@@.@..@@..@@.@@@@.@@@@@.@@@@@@@..@.@@....@@.@@.@@@ +@@@@@@@.@@@.@@@@@@@..@@..@.@@@@.@@...@@..@@@@@.@@..@@@.@.@@@..@.@@@@@@.@@@@@.@.@.@@@..@@.@@.@@@...@@...@@.@@@@@..@@@.@..@@....@@@..@@@@.@.. +.@@..@.@.@@..@..@@@.@@...@@...@@.@.@@@@@@.@.@@.@@@@@@@@.@@.@@@@..@..@.@..@@@..@@@@....@.@.@@@@@..@.@@@@@@@@@.@@.@.@@.@@.@@@.@@@.@@@@.@@@@@@ +@@@......@@@.....@@@..@.@@@...@.@@@@@@@.@.@@@@@.@.@@@@@..@.@@@.@@.@@@@@@@@@.@.@@@.@@@.@.@@@@..@@@@..@@@@.@.@..@...@@...@..@@@.@....@@.@@.@. +@@@.@@@@@@@@@@@....@..@@@.@...@@@@@@@.@@@@.@.@@..@@...@@@@@.@@@@@...@..@.@.@@@..@@@@@.@.@.@.@@@.@@@..@.@@@@@@.@@@@@@.@@@@@@@@@@.@@.@..@@@@. +.@@@.@.@.@.@@@@@....@.@@..@@@@..@.@@@@@@.@.@@@@@.@@@..@@@.@.@@@.@@..@@..@.@.@@@@.@@@@.@.@..@..@.@@@.@.@@@@@.@.@@@.@@..@@@@@@@.@@@@..@@@@..@ +@@.@@@..@.@.@.@@@@.@@@@@.@@...@.@@@@@@..@@@@.@.@@@@.@@@@@@@@@.@.@@...@.@@@..@.@.@@@@@@@.@.@@.@@@.@@.@@...@...@.@@@..@.@.@..@.@@@@@@@@.@@@@. +@@@@@@@@.@..@@@@@@@.@.@@@@@@..@.@@@@@@@..@..@@@@@@@@@@@@@@@@@@.@@@@@@@.@@@@@@@@@@.@@@@@@@.@.@@@.@.@@@@@..@.@@@@@...@@.@@@@..@@@@..@@@.@@@@. +.@@@@@.@@@@@.@.@@@@@@@..@@@@@@@@@.@@@@.@@.@...@@.@@@@@@.@@@@.@@@@@@.@@@@@@...@@@..@@@@..@.@.@.@@@@@@@@@@.@.@@@@@@@@@..@@.@@@@.@...@@@@@.@.@ +@@@@.@@@.@@@@@@...@@..@.@...@@@.@@.@.@.@....@@@...@@....@@....@.@@@@@@@...@...@@@@@@@@@@@@@@@@@...@@@@@@@@@.@.@@@.@@@@@@@@@@@@@@.@@@@@@@.@. +@@@@@@.@@@.@@@..@@@.@.@.@@.@@.@..@@@.@@..@@.@@@@.@.@.@@@@@.@.@@........@@.@@.@@.@@..@.@@.@.@..@@@.@@....@@@@.@.@@@..@..@.@@..@@@.@@@.@.@@@. +..@@.@@@@@@.@@@..@@@.@.@@@@.@.@@.@@@.@.@@@@.@.@.@.@@.@..@@@@@......@.@@@@.@@@.@@.@@@@@@.@@@@.@@...@@.@.@@.@@.@.@@.@@.@@.@@.@@@@@@@.@@@@@.@@ +@..@...@.@@@@@@@@...@@@@@@..@@....@..@@@@.@.@.@@@@@@@..@..@@@@.@@.....@..@.@..@@.@..@@@..@.@@@@@.@@@..@@@@@@@@.@@@@@@.....@@.@@.@@.@@..@..@ +@@@@.@.@@@..@.@@@..@@@@@@@@.@@....@..@@..@@.@.@.@@.@@.@@@@.@.@.@@..@@.@..@..@@@..@@...@.@@@@@@@.@@.@@@@.@@@@.@@@..@..@.@@.@@@@@.@@.@@@...@@ +.@@@.@@.@.@..@.@@..@....@@@@@@.@@.@@.@.@@.@.@@@..@@.@..@.@..@@@@@..@@..@@@.@..@@@...@.@@@@@..@.@..@@...@@.@@..@.@@@@@...@@.@.@.@@.@@@@@@@@@ +@.@@@@@.@@..@@.@.@@@@@@@.@@.@@@@@@@@@@...@@@@.@..@.@@@..@.@@@@@@@.@@.@@...@.@@@@..@@@@.@@.@@.@@@@@.@.@.@.....@@.@@..@@@@@@@@..@.@.@@@@.@@@. +@@.@@@@.@@@.@@@.@@.@@@@@@@..@@..@.@..@...@@@.@@@@@@@@@@@@.@@.@@.@@..@@@.@@@.@...@@.@@@@@@@@.@.@@@...@@..@.@.@@@@@@.@@@...@@@..@.@..@.@@.@@@ +.@@.@@@@@@@@@...@@.@@@@@@@@..@...@.@@@.@@.@@@@@@@@@.@@@@@@@@@@@@.@@@@@.@..@.@.@@@...@@.@.@@....@@..@@@@@@.@@@.@@@.@@@..@@@@@@.@@.@.@@..@.@@ +@.@..@@..@@@.@..@@@.@@.@..@@..@...@@.@.@@@.@@@....@.@@@@@@.@.@.@.@.@@@.@@.@@@@@@..@.@@@@@.@@@@@.@.@@@.@@@@@..@.@.@.@@@@@.@@@@@@@@@@@.@@..@@ +.@@@..@@@@@@@@@@@@@.@..@@.@.@@@@@@@@@.@.@@.@@@@@@@@@@.@@@@..@@@.@@@@@.@@@@@..@.@@...@@@@@@@....@@.@@@@@.@@@@.@@@@..@@@@@@@.@.....@.@@@.@@.. +@@@@@@@@@.@@@@..@@@@.....@.@@@@@.@.@@@@@@.@@@.@..@@@...@@@@@@@@@@@.@@@...@@@@.@@@@@@.@@..@@.@...@@@@@@@..@@@@@.@.@@@@@@@@@.@..@@@.@@@@@@@.. +@@@...@@.@@...@@@.@@.@@@@@@.@@@.@@....@.@.@@@..@.@@@.@.@@..@@@.@@.@@@@.@@@.@.@.@@@..@@@..@@@@@@@@@..@@@.@.@..@.@@.@@@...@.@@@@@.@@..@@@@@.@ +@@.@@...@@@.@@@.@@.@.@@@@@.@@@@@.@..@@@@.@@.@@@@@.@@.@@@@@@@.@.@@@..@@@@@@...@@@@@.@.@@@.@....@@@@@@@@@@@@@.@@.@..@@@@@@@@@@@@.@@@.@.@.@@.@ +@.@.@@@.@.@.@@@@@@@@@@.@@.@@@@....@..@@..@@@.@.@.@.@.@.@@@@..@@.@@@@@..@@@.@@@.@@@@@@@@@@.@@@@@@@@...@@@@@@@@@.@@@.@@.@@.@...@@@.@@@@.@...@ +..@@@@@@...@.@@@@@@@@...@...@@@.@@.@..@.@.@@@.@.@@..@@@.@.@.@.@@@@@@@@@@@.@@@@@@@.@.@@@@.@..@@@.@..@.@@..@...@@..@@@..@@..@.@@@@.@.@@..@@@@ +@@.@@@@@@@.@@.@..@@@@..@@@@@@@@@@@@@...@@@...@@.@@@@@@@@@@@@@.@@@.@..@..@.@@@@@@.@@@@@.@.@@@@@@@.@.@@@@.@.@..@@@@.@@.@@.@@@@.@.@.@@@@@..@.@ +@@@@@@.@.@...@.@@@@@@...@@@@@@@@.@@@@@@..@@@..@@@@@.@@@@@.@@@.@@.@@@@@.@@.@@@@@@@@@@..@..@@@@@@.@@@@.@...@@.@@@.@@.@...@@@@@@.@@@.@.@..@.@@ +.@@@@@...@.@...@@.@.@..@.@...@@@.@@@@@@@..@@@@@@..@.@@@@@@@@@..@@@@@@@@@@@..@@@@@@@@.@.@@@@..@@@@@@@...@..@@.@.@.@.@..@.@@@@@@@@..@@@@@@..@ +@@@@@@....@..@@.@@..@@@@.@@@@@@@.@@.@@..@@@@@@@.@.@@.@@.....@.@@@@@@..@.@@..@..@..@@@@@.@@.@@@@@@.@@@.@@@.@.@@@.@@@.@@.@@@@.@...@@@@@..@.@. +@@@..@.@.@@@.@@@@@@.@.@@@@@@..@@.@@.@@@@....@@@.@@@.@.@.@@@@@..@@@.@@@@..@@.@.....@@..@.@@@.@.@@@.@@@@@@.@@..@@.@..@@.@@@@@@@.@@@...@@@@@@@ +...@@@@@@@@.....@.@@.@..@@..@@.@.@.@.@@..@@@@@@@@@...@@@@@@..@@..@@@.@@@@@@@....@.@@.@@@@@@.@@@@@.@@@@@@@@@@@@@.@.@@@@@@..@.@@@@@@..@@@@@@. +@@@@.@@@@@.@@@..@@.@@@@@.@@@.@@@...@@@.@.@.@@.@@@@.@.@@@@.@@@@..@.@@.@...@@@@@@@@@.@@@@...@.@.@@@.@@@..@@.@..@.@.@@..@@.....@@@@.@.@@.@@.@@ +..@@......@@.@@@.@@..@@@@@..@@..@@.@@@@@@@@@@.@.@@@.@@@@....@@@@..@..@@..@@@...@@.@.@@@@...@@@@@@@...@@@@.@.@.@@@...@@@.@@@@@.@@@.@@....@.@ +@.@@.@@..@@@@@@.@.@.@.@@@@@@..@..@@.@@.@@..@.@.@.@..@..@.@@@@..@@@@.@@@@@.@@.@.@@@.@@.@@.@..@@...@@.@.@@@.@@@@.@@@@.@@@@..@.@...@@@@@@@@@@. +.@@..@@.@@@.@..@@@@....@@@..@..@@@.@@@@@@@@@.@@@.@@@@@@..@@@@@@@@@..@@@..@.@@.@@@@....@@@@@..@@.@@@..@@@.@@@@.@.@.@@@@@@@..@..@@@@...@@@@@@ +@.@@@@.@@@@@.@.@.@@.@@@.@@.@.@.@@..@.@..@@@@@.@@..@@.@@@@@@.@..@@@...@.@..@..@@@@...@@@@.@@@@@@@..@..@@@.@@.@@@@.@..@@..@@@@@..@.@@@@@@.@.@ +@@@@@@@.@@@@..@@@@@@@@.@@@@@@@@@@@@@@@@.@.@..@@...@@.@@.@@@.@@@@..@.@@@@.@.@.@@@@@....@.@@@..@@@@..@@@@.@@@@@@@@...@@..@.@.@@@@@@@@@@...@.@ +@@@@@.@.@@@..@@@@..@..@@...@@@.@@.@@@.@@.@@@.@.@@@@@..@..@.@...@@@@@.@@@@@@@@@.@.@@@@@@.@@.....@@@..@@@.@@@@@.@.@@@.@..@.@.@.@@@@.@@@..@@@@ +.@@@@@@@.@@.@@@@@@.@@...@@@@.@@@@.@@.@@@@.@.@....@.@.@@@@@@.@..@.@@@@@@@@@...@@.@.@......@.@@..@...@@@@@@.@.@@@@..@@@.@.@@@....@@@.@.@@@@@. +..@@@@@@@@.@@.@@.@.@.@@@@..@..@@.@...@@@.@@@@@@.@..@..@@.......@@.@@@@@@@@@@@.@....@...@..@.@@@....@.@.@.@.@@@@@.@.@@@@@.@@@@@@@@...@@@@.@. +@.@@@.@.@@.@@..@@@...@@.@@.@...@@@...@@@@@..@.@@..@...@@@.@@@@@.@@@@@@@.@@@@.@@@.@@@.@.@@@..@@@@@.....@@@@@@@..@@@.@.@@.@.@..@...@@@@@@@@.@ +@@@..@.@@@.@.@@..@@@@...@@.@.@@@.@@@@...@@..@@@@@@.@..@...@@@@..@@..@@@@@......@.@@@@@@@.@@@@.@@@.@@@.@@@@@@@@@@@.@.@@@@...@.@@..@@@@@@@@@@ +@@@@@@@@@@@.@@@@@@@@@@@@@@.@.@..@@.@@@@.@.@.@@@..@@@@@.@@@@.@@@...@@@.@..@@@..@.@@@@@.@@..@@.@@@@@...@@@@.@..@..@.@.@@@@@@@@.@@@.@.@@@@@..@ +@.@.@@@@@.@.@@@.@@@...@.@.@.@.@@@.@.@@.@@@...@@@@@..@.@@@@.@@@@@.@.@.@@@..@.@.@@.@.@.@@@@..@.@.@@@@@@@.@@@..@@@.@@.@..@@@.@.@@@@@@@.@..@@.@ +..@...@@@@@.@..@@@..@.@@@@@.@.@@.@.@@@@.@.@.....@@.@@@.@@@@@@@@..@@@..@.@..@.@@@@@@..@@.@@..@..@@@..@@@.@..@@...@@.@.@@@@@.@.@@@@.@.@@@@@.@ +.@@@@@@..@@@@..@@@..@@@@@@.@@@@.@.@@@@..@@@@@.@@@@...@@.@@@...@@@@..@@.@..@@@@@..@...@@@@@..@@@.@@@@@@.@@@@@@@@..@@.@@@@.@.@..@@.@.@@@.@@.@ +.@.@@.@@@@.@.@@@..@@.@.@@..@.@@@@...@@...@.@@@@@.@@.@.@@.@.@...@..@..@@..@...@....@.@@..@@@@.@.@.@.@@@@@@..@@.@@@@@@@.@@.@.@.@@.@@@..@..@.@ +...@.@@@@..@@@@.@...@..@.@@@.@@@@.@@@@@@@.@@@@@@@@@@@@.@@@.@@.@@.@@@.@@..@..@.@@@@@.@@@@@@@@@.@@@@.@@@@@@@.@@@@@@..@@@@@@@.@..@@.@...@@@@@@ \ No newline at end of file diff --git a/src/day4/mod.rs b/src/day4/mod.rs new file mode 100644 index 0000000..4d9325f --- /dev/null +++ b/src/day4/mod.rs @@ -0,0 +1,99 @@ +use std::{fs, io::Cursor, ops::Index}; + +pub fn solve() { + let file = fs::read_to_string("src/day4/input.txt").expect("You didn't provide input.txt."); + + let mut lines = file.lines().into_iter(); + + let mut previous_line = Option::<&str>::None; + let mut opt_current_line = lines.next(); + let mut next_line = lines.next(); + + let roll_symbol = "@".chars().next().unwrap(); + let mut accessible_rolls_count = 0; + + while let Some(current_line) = opt_current_line { + for (idx, el) in current_line.char_indices() { + if el != roll_symbol { + continue; + } + let mut adjacent_rolls_count = 0; + + if idx > 0 { + let left = current_line[(idx - 1)..].chars().next().unwrap(); + if left == roll_symbol { + adjacent_rolls_count += 1; + } + } + + if idx < current_line.len() - 1 { + let right = current_line[(idx + 1)..].chars().next().unwrap(); + + if right == roll_symbol { + adjacent_rolls_count += 1; + } + } + + if let Some(previous_line) = previous_line.clone() { + { + let above = previous_line[idx..].chars().next().unwrap(); + + if above == roll_symbol { + adjacent_rolls_count += 1; + }; + } + + if idx > 0 { + let above_left = previous_line[(idx - 1)..].chars().next().unwrap(); + + if above_left == roll_symbol { + adjacent_rolls_count += 1; + } + } + + if idx < previous_line.len() - 1 { + let above_right = previous_line[(idx + 1)..].chars().next().unwrap(); + + if above_right == roll_symbol { + adjacent_rolls_count += 1; + } + } + } + + if let Some(next_line) = next_line { + { + let below = next_line[idx..].chars().next().unwrap(); + + if below == roll_symbol { + adjacent_rolls_count += 1; + } + } + + if idx > 0 { + let below_left = next_line[(idx - 1)..].chars().next().unwrap(); + + if below_left == roll_symbol { + adjacent_rolls_count += 1; + } + } + + if idx < next_line.len() - 1 { + let below_right = next_line[(idx + 1)..].chars().next().unwrap(); + + if below_right == roll_symbol { + adjacent_rolls_count += 1; + } + } + } + + if adjacent_rolls_count < 4 { + accessible_rolls_count += 1; + } + } + previous_line = Some(current_line); + opt_current_line = next_line; + next_line = lines.next(); + } + + println!("{}", accessible_rolls_count); +} diff --git a/src/day4/sample_input.txt b/src/day4/sample_input.txt new file mode 100644 index 0000000..8209399 --- /dev/null +++ b/src/day4/sample_input.txt @@ -0,0 +1,10 @@ +..@@.@@@@. +@@@.@.@.@@ +@@@@@.@.@@ +@.@@@@..@. +@@.@@@@.@@ +.@@@@@@@.@ +.@.@.@.@@@ +@.@@@.@@@@ +.@@@@@@@@. +@.@.@@@.@. diff --git a/src/main.rs b/src/main.rs index 5e17ef2..529e899 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ mod day1; mod day2; mod day3; +mod day4; fn main() { - day3::solve(); + day4::solve(); }