23
๐ฌ - 2026 DAY 3 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')
Indeed; very nice. Saves wasting loads of time checking for 'every possible grid and skew' like I was doing, since it only checks possibilities, and would scale very well to truly enormous grids of trees.
I tried it and my code got slower :(
Mostly because the hashset lookup is just brutally slow for some reason.
You're probably doing way too many hashing checks, my version prunes a lot of incorrect pairs (where second corner is above or to the right of the first) cheaply.
But you also don't need hashset here at all, you can just index into the existing grid e.g.
grid[y][x] == '#'.Priming the hash checks didnt help, but now you mention it, just indexing into the grid is very obvious...
Edit: down to 22ms, completely dropped hashset. Still not quite happy, but getting there!