Solutions for Advent of Code
After working overtime to solve day 12, this brief task was a much welcome change. For pt 1, the code uses integer division and modulus to update all positions. The tricky part was to determine which quadrant got the middle column and row (since dimensions was odd numbers, and either left or right quandrants is +1 longer), which was straightforward to verify by the test cases. For pt 2, the remains of the code used to visually identify the tree is left under the `find_easter_egg` toggle. Basically, the code prints the grid with all robots marked as a `#`, and free space as `.`.` This wording of the puzzle is important: > very rarely, _most of the robots_ should arrange > themselves into a picture of a Christmas tree. "most of the robots" means the tree will be quite visible, which also means it is safe to asume a significant cluster of "#" would appear over time. By keeping track of the counter (seconds the robots has traveled), it was evident that the cluster of `#` occoured th first time at i=64 and every 103th time forward. In other words, `i % 103 == 64` will most likely give a tree. The print statement is therefore limited to those i's, and at `i == easter_egg_appearance` the tree is visible. So, to be extra clear: 64, 103 and pt2 answer is unique to my puzzle input. If this code is used with any other puzzle input, these numbers will most likely vary. For the fun, the code also contains the `display_easter_egg` flag to actually print the tree. This is provided to indicate how big the actual tree is: 33*36 chars. Also, the `sints` utility function was added to extract all signed ints from a string. |
||
|---|---|---|
| 2015-elixir | ||
| 2015-elixir-2 | ||
| 2015-python | ||
| 2016-python | ||
| 2016-python2 | ||
| 2017-python | ||
| 2018-elixir | ||
| 2018-python | ||
| 2019-elixir | ||
| 2020-elixir | ||
| 2020-python | ||
| 2021-elixir | ||
| 2021-python | ||
| 2022-elixir | ||
| 2023-python | ||
| 2024-python | ||
| leaderboard | ||
| .gitignore | ||
| fetch-calendar | ||
| fetch-input | ||
| README.md | ||
Advent of Code 2015–
Here all solved puzzles for Advent of Code are kept for reference. Most solutions are written in Python, but there are also solutions written in Elixir.
- Initial runs from 2016–2020 are squashed in version control, so the original thoughts/rants about the solution are forgotten for future generations.
- 2021 onwards, each solution will have a separate commit. This also includes revisiting old events.
Where are the puzzle input files?
For many years, this repository had all puzzle inputs under version control. They are not anymore, although the scripts asumed they are downloaded and stored locally in a subdirectory, which is ignored by version control.
The reasons:
- Neither you or me do have permission to reproduce or redistribute them, they are not released under public domain or MIT/BSD/GPL or any other license.
- The author behind advent of code have kindly asked us who attend Advent of Code to not release them, since publiced puzzle inputs cen be used to copy the site and steal the AoC creator's work.
Sources: