Day 9 wasn't too bad. I probably should have reached for results or optoinals for some things instead of branches with one side being a crash. Debugability wasn't great. Had a panic due to a typo (subtraction where I should have had addition). Would be solved if the cli platform printed a bracktrace when roc panicked.
https://github.com/bhansconnect/roc-aoc-2021/blob/trunk/day9/part2.roc
Added a pr to give us backtraces on the cli platform: https://github.com/roc-lang/roc/pull/4258
I made some cosmetic cleanups to the trace! Screen-Shot-2022-10-08-at-3.01.45-PM.png
PR: https://github.com/roc-lang/roc/pull/4261
That's awesome!
https://github.com/ghigt/advent-of-code/blob/main/roc/day-9/part2.roc
I thought it was an easy one, but I'm stuck on the part2 :sob:
I compared each values of part1 with @Brendan Hansknecht solution and I have the same one, I tried my part2 with the example and I get the good result but for the real data, I get a wrong answer. If someone understand what's wrong in my implementation, I would be happy to know!
Only gave it a short scan, with no testing, but this line looks wrong to me: https://github.com/ghigt/advent-of-code/blob/f105bd13bdfd757913ab0d38d2a5d9b02002c300/roc/day-9/part2.roc#L55
Should y.x == x + 1
be y.x > x
?
maybe should even be >=
, but I would need to re-look at the problem
You're absolutely right, I didn't understand the instruction. :man_facepalming: so close... :sweat_smile: thank you!
Last updated: Jul 06 2025 at 12:14 UTC