23
๐ - 2023 DAY 6 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 | 19 | 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')
Rust
I went with solving the quadratic equation, so part 2 was just a trivial change in parsing. It was a bit janky to find the integer that is strictly larger than a floating point number, but it all worked out.
(number+1).floor()
does the trickOh yeah, that's clever. I'll remember that when it comes up again.
In Python when using numpy to find the roots, sometimes you get a numeric artifact like 30.99999999999, which breaks this. Make sure to limit the significant digits to a sane amount like 5 with rounding to prevent that.
I wanted to try the easy approach first and see how slow it was. Didn't even take a second for part 2. So I just skipped the mathematical solution entirely.