12
☃️ - 2023 DAY 11 SOLUTIONS - ☃️
(programming.dev)
An unofficial home for the advent of code community on programming.dev! Other challenges are also welcome!
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.
Everybody Codes is another collection of programming puzzles with seasonal events.
Solution Threads
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 |
Icon base by Lorc under CC BY 3.0 with modifications to add a gradient
console.log('Hello World')
Nim
Part 1 and 2: I solved today's puzzle without expanding the universe. Path in expanded universe is just a path in the original grid + expansion rate times the number of crossed completely-empty lines (both horizontal and vertical). For example, if a single tile after expansion become 5 tiles (rate = +4), original path was 12 and it crosses 7 lines, new path will be:
12 + 4 * 7 = 40.The shortest path is easy to calculate in O(1) time:
abs(start.x - finish.x) + abs(start.y - finish.y).And to count crossed lines I just check if line is between the start and finish indexes.
Total runtime: 2.5 ms
Puzzle rating: 7/10 Code: day_11/solution.nim
Snippet: