20
❄️ - 2023 DAY 3 SOLUTIONS -❄️
(programming.dev)
An unofficial home for the advent of code community on programming.dev!
Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.
Solution Threads
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 18 | 20 | 21 | 22 |
23 | 24 | 25 |
Icon base by Lorc under CC BY 3.0 with modifications to add a gradient
console.log('Hello World')
Language: Python
Classic AoC grid problem... Tedious as usual, but very doable. Took my time and I'm pretty happy with the result. :]
Part 1
For the first part, I decided to break the problem into: 1. Reading the schematic, 2. Finding the numbers, 3. Finding the parts. This was useful for Part 2 as I could re-use my
read_schematic
andfind_numbers
functions.Two things I typically do for grid problems:
DIRECTIONS
list I loop through so I can check easily check the neighbors.Part 2
For the second part, I just found the stars, and then I found the gears by checking if the stars are next to two numbers (which I had found previously).
GitHub Repo