Here's my solution, today was a lot of fun building a mini compiler. :smile:
https://github.com/lukewilliamboswell/aoc/blob/main/2024/07.roc
TIMING:
READING INPUT: 1ms
SOLVING PART 1: 205ms
SOLVING PART 2: 11225ms
Also, loving this snake_case
... it's my first time using it.
https://github.com/ostcar/aoc2024/blob/main/day07.roc
part1 in 59.307ms
part2 in 813.36ms
Part 2 has an obvious performance problem. Can you spot it?
Lol, my solution looks like overkill :sweat_smile:
I like how much smaller and efficient your's is @Oskar Hahn
I know, this could be better
Lol, don't look at my implementation, haha
Luke Boswell said:
I know, this could be better
Lol, don't look at my implementation, haha
Ok, I had to fix this. But a Num.log10 would have been nice.
Agreed that Num.log10 would have been nice: https://github.com/RobinCamarasa/Advent-of-code/blob/master/2024/day07/RobinCamarasa/main.roc
I also went for naive implementation xD
https://github.com/thenikso/advent-of-code-2024-roc/blob/main/07.roc
Day 07 part 1: (Ok ...) [134ms]
Day 07 part 2: (Ok ...) [13854ms]
I got the answer initially with the naive solution but a more optimal way to do it is to work backwards. Filter out which final operators are possible based on if the desired result can be a result of applying the last operand with said operator, then apply the inverse of that operator, pop the last operand, and see if that has a solution. Pretty clever imo, but I didn't come up with it.
https://github.com/mckahz/aoc/blob/main/2024/Day07.roc
Part 2 really makes you wish you read the requirements a few times
I'm not proud at all of my solution's perf, but I think it is very readable ( I did have to do a slight tweak to make the perf for part 2 even reasonable)
https://github.com/gamebox/aoc-2024/tree/main/day7
I know I could take a few different approaches to bail out of checking different combinations earlier
No trouble
SOLVING PART 1: 489ms
SOLVING PART 2: 36166ms
main_claude.roc
prompt-aoc-7-part2.txt
Last updated: Jul 06 2025 at 12:14 UTC