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')
Elixir
For part 1 I iterated over the lists and took some time figuring out what the end condition for this should actually be. Not really proud of this part but it works.
So for part 2 I started over and did it with an approach kind of using a starting point, vector to a second point and then calculating point 3 and 4 from there. Then each point is checked wether it's out of bounds and if it has a tree planted there. It's taking a few seconds to complete so it's not running really fast but I like the approach more than my part 1 and it could probably be optimised by rearranging some checks so it stop checking earlier.
Edit: Rearranging checks doesn't do much, this approach is just slow. It's probably better to get the coordinates for all trees and work with that as some other solutions did.
solution