42
๐ฆ - 2024 DAY 2 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')
Rust
The function is_sorted_by on Iterators turned out helpful for compactly finding if a report is safe. In part 2 I simply tried the same with each element removed, since all reports are very short.
is_sorted_byis new to me, could be very useful.The
is_sorted_byis a really nice approach. I originally tried using that function thinking that|a, b| a > bor|a, b| a < bwould cut it but it didn't end up working. I never thought to handle the check for the step being between 1 and 3 in the callback closure for that though.