From 0e09b89f510ed911fb91ad78c5627ca37117b427 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Thu, 19 Dec 2024 14:06:24 +0100 Subject: [PATCH] 2024(6): pull in puzzle --- 2024/06/README.md | 108 ++++++++++++++++++++++++++++++++++++++ 2024/06/input | 130 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 238 insertions(+) create mode 100644 2024/06/README.md create mode 100644 2024/06/input diff --git a/2024/06/README.md b/2024/06/README.md new file mode 100644 index 0000000..cf59bf1 --- /dev/null +++ b/2024/06/README.md @@ -0,0 +1,108 @@ +# Day 6: Guard Gallivant + +[https://adventofcode.com/2024/day/6](https://adventofcode.com/2024/day/6) + +## Description + +### Part One + +The Historians use their fancy [device](https://adventofcode.com/2024/day/4) again, this time to whisk you all away to the North Pole prototype suit manufacturing lab... in the year [1518](https://adventofcode.com/2018/day/5)! It turns out that having direct access to history is very convenient for a group of historians. + +You still have to be careful of time paradoxes, and so it will be important to avoid anyone from 1518 while The Historians search for the Chief. Unfortunately, a single _guard_ is patrolling this part of the lab. + +Maybe you can work out where the guard will go ahead of time so that The Historians can search safely? + +You start by making a map (your puzzle input) of the situation. For example: + + ....#..... + .........# + .......... + ..#....... + .......#.. + .......... + .#..^..... + ........#. + #......... + ......#... + + +The map shows the current position of the guard with `^` (to indicate the guard is currently facing _up_ from the perspective of the map). Any _obstructions_ - crates, desks, alchemical reactors, etc. - are shown as `#`. + +Lab guards in 1518 follow a very strict patrol protocol which involves repeatedly following these steps: + +* If there is something directly in front of you, turn right 90 degrees. +* Otherwise, take a step forward. + +Following the above protocol, the guard moves up several times until she reaches an obstacle (in this case, a pile of failed suit prototypes): + + ....#..... + ....^....# + .......... + ..#....... + .......#.. + .......... + .#........ + ........#. + #......... + ......#... + + +Because there is now an obstacle in front of the guard, she turns right before continuing straight in her new facing direction: + + ....#..... + ........># + .......... + ..#....... + .......#.. + .......... + .#........ + ........#. + #......... + ......#... + + +Reaching another obstacle (a spool of several _very_ long polymers), she turns right again and continues downward: + + ....#..... + .........# + .......... + ..#....... + .......#.. + .......... + .#......v. + ........#. + #......... + ......#... + + +This process continues for a while, but the guard eventually leaves the mapped area (after walking past a tank of universal solvent): + + ....#..... + .........# + .......... + ..#....... + .......#.. + .......... + .#........ + ........#. + #......... + ......#v.. + + +By predicting the guard's route, you can determine which specific positions in the lab will be in the patrol path. _Including the guard's starting position_, the positions visited by the guard before leaving the area are marked with an `X`: + + ....#..... + ....XXXXX# + ....X...X. + ..#.X...X. + ..XXXXX#X. + ..X.X.X.X. + .#XXXXXXX. + .XXXXXXX#. + #XXXXXXX.. + ......#X.. + + +In this example, the guard will visit _`41`_ distinct positions on your map. + +Predict the path of the guard. _How many distinct positions will the guard visit before leaving the mapped area?_ diff --git a/2024/06/input b/2024/06/input new file mode 100644 index 0000000..5e11580 --- /dev/null +++ b/2024/06/input @@ -0,0 +1,130 @@ +................#.................#.#...........................#.#..................#............................................ +..........#................#...........#...................#.#.................................................................... +....#......#......#............#.#........#..........#.......#.......#...#........#..........#.........................#.......... +..................#............#.....##...............#..#.....................#...........#...................................... +#.........#.............................................................#........#............#........#.....#...#...........#.... +.....#...#......#..................................................#........#..................#......#.......................#... +#.................................................#......................#......#...................................#............. +...#.#...#.....................................#.......................#.........#..................................#....#........ +..............................................#..............#...#...........##..........................#.......#............#... +........#.#.......#.................##.......................#..........#...........................#...#......................... +.................#..............................#.................#............#....#.....#....................................... +.................................................................#......#............#.#.#..................#..................... +.#..........#......#...#.......#..........................#....................#.#.............................#.................. +...............#.....##.......#..#...###......#......................#.................................#.#......#..#.............. +#.....................#......................................#..........#...............#........#...............#...#.#.......... +.......................................#..................#.........................#............................................. +.......................#...............................................................#........................#...........#..... +......#....#..........................................................................................#..........#................ +........#.......................................#..........................#.............##.........#............#.#.........#.... +......#........#........................................................#..........................#.............................. +....................#.................................................#.....................#......#..#...#....................#.. +...........#....................##.....#...#............#...#......................................#.....#.......#.........#....#. +#..............#.................#......#..................#...................#......#...........#............................... +.......#.......#.........................................#.....#..#.................................................#..........#.. +..#..................#.......................#..#..#...#..........................#.........#...##......#..........#.#..#......... +..#.........#....................#...........................#....................#..........................#................#..# +......#.....................................................#..#.......#.............#...................#......................#. +.....#..................................................................#...#.....................#......................#.#...... +......#..............#...................................#.......................#...................................#...##....... +...........#..........#....................................................................#........................#............. +#.......................................#..........................#........#......#......................##...................... +.............#...#..........#......#..........#.#......................................................................#.......... +........................................................#....#...#......##..........................#..........#.................. +.#...#.....#..........#....#...........................................#........#....................................#............ +....#....................................##.......#...........................................#.......#........................... +...........#.............#........................................................#...#................#........#................. +.....#.#........................................#....................#.........#.................................................. +.........#............#..............................#...#..............#...........................#...............#.....#....... +......................#........................................#.#..........#...#..#......................#....................... +##...........#..............#......#....................#..........................#.......................#.......#.......#...... +....#..#.........................................................#.....#..#.........................................#.....#....... +....#......##................#......................................#.......................................#..................#.. +..............................#............................#..................#.......#.......#..................#...#............ +......................................................#............................#.............................................. +.......#.............................#......#.................................#................................................... +..................................................................................................................#............... +.......................#.....#...........##........................................#..............................#............... +..........................#................................................................#..................#................... +..........................#..................#........#..............#.#..#...................##.................................. +..................#............................................................................................#.................. +.......................#..........#...##................#......................................................................... +...............#.....................................#............................................#............................... +....#..................................................................................#........#................................. +..#................#.....................................................................#...#.................................... +..........#.............#.........#......#................#......#.........#........#.......................#..................... +..........................................................................#.................................#.....#....#.#........ +....#..........#......................................#......................................................#.......#....#.....#. +.....#...............................#............................#........................................................#...... +.............................................................................#.......................#....................#..#.... +................#.............................................................#................................................... +.....#................#.......#....................#............#.......#.....#.................................#................. +...........................................................................................................#.#.................... +.....#...............................................#...................................................................#..#..... +................#..............................#.............#.#..............................................................#... +..#............#...................#..................................................................#...............#...#....#.. +..........#...............#...............#............................................#......#...##........#..#.................. +......#..###..........................................................................................#................#.......... +..........#........#.....#.......................#.........................................#.#........#.#......................... +.....#............................................................#.....#..........................#.............................. +...............................................................#..............#........................................#.......... +.................................................#....#...#....................................#..#........................#...... +.................#..........#......#......................#.......#...................#.#......................................... +.#............................................................................#..............#..............................#..#.. +..#........#...#..........#.................#...#...................................................#...#............#............ +...........#.......#..#...............................................................................#........................... +.#.#..#...........##...................#...................................#...........#...............................#.......... +......................................................................#............#.....................................#...#.... +....#............#.#.#................#............#....#...#......#....................................................#......... +.......................................................................................#.....................................#.... +.......................................#..................#........#................................................#............. +.........................................#.....#..........#.......##..................................#................#.......... +..............#.............#............#..........................................................#............................. +.#...................#...#..........................................................#........#........#..........................# +..#..............................#.....................................#.................#.............#...........#.............. +.................................#........................#.#....#......#....................#.................................... +.#..................................................#.....#............................#..........#..................#.......#.... +.....................#.......................^............#...#...#..............#................#............................... +.........#....................................#....................#...........#...........#..............#...................#... +............................#...........#....................#.............#.......#.......................#...#....#............. +............#.................#...........#..................................................................#............#....... +...........#....................#.................................................#......#.#....................#................. +..............................................................#..........#........#....#.........#................................ +...............#.........#......#..........#.#.............................................................................#....#. +...............##...##..........................................................................................#................. +..........................#.#...........................#......................#...............#.................................. +.....#...#..................#...........#....#.........#............................#............................................. +.........................................................................................#...................#...#................ +............#.....................#...........#..................................................................#................ +.#.............................#............................#..........#......##...................................#.#............ +............#.........................................#...............................................#.#....#.................... +.........................................................#..#.#...............#......#....#........#..........................#... +............................#..#.................#................................................................#............... +............................#.........................................................................#....#..#............#..#... +....#........#....#....#..#..............................#...#......................#.......................#............#........ +..#...............#............................................................................................................#.. +#.......................#...#............#..................................................#.........................#........... +.....#.................#..#.............................................#...................................................##.... +...............#....................................#................#.........................#.#...........................#.#.. +.................#....#....#..............#....#.#....#...............#......................#...............#..................#. +...........#...............................................................................#....#.................#............... +...............#............................................###.#.#.#........#...................................#....#........... +................#.................#........#............#..............#.....................#.............#...................... +....................................#.....................................................#....#.................................. +..#..#.............#......#.#..................#........................................#..........#...#.......................... +...............#........................#...............................#.............#...................#..#....#............... +......#...........................#..............................................#..............................#...............#. +...........#..............#................#....#..........#................#.......#..............#.........#.................#.. +......#....................................................................................................#...................... +...........#.............#...............#..........#....#.#...##..................#....................#......................... +.......................................................#.#.....................................#..................#.......#....... +...............#...............#...........................................................................#..................#... +...............#......#.........#..................#.............................#..............................#................. +...............#..........#..#.......#.............#............................#.#............................#.................. +..........#................................#..#................................................................................... +..#................#............#........#...................................#...............##.................##....#.......#... +..#.....................................................................#.............................................#.#......... +#...#...#.......................##............#..............#.........#......................#........#.#........................ +..............................#......#.......#.........#...#..#.......................................................#.#......... +.#..................#.#................................#..........#.......#..........................#............................ +...............#.....................#...#..........................................#..........#......#...........................