Stream: advent of code

Topic: 2024 Day 7


view this post on Zulip Luke Boswell (Dec 07 2024 at 06:41):

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

view this post on Zulip Luke Boswell (Dec 07 2024 at 06:41):

Also, loving this snake_case ... it's my first time using it.

view this post on Zulip Oskar Hahn (Dec 07 2024 at 10:06):

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?

view this post on Zulip Luke Boswell (Dec 07 2024 at 10:08):

Lol, my solution looks like overkill :sweat_smile:

view this post on Zulip Luke Boswell (Dec 07 2024 at 10:08):

I like how much smaller and efficient your's is @Oskar Hahn

view this post on Zulip Luke Boswell (Dec 07 2024 at 10:10):

I know, this could be better

Lol, don't look at my implementation, haha

view this post on Zulip Oskar Hahn (Dec 07 2024 at 13:31):

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.

view this post on Zulip Robin Camarasa (Dec 07 2024 at 13:56):

Agreed that Num.log10 would have been nice: https://github.com/RobinCamarasa/Advent-of-code/blob/master/2024/day07/RobinCamarasa/main.roc

view this post on Zulip Nicola Peduzzi (Dec 07 2024 at 17:16):

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]

view this post on Zulip Fletch Canny (Dec 08 2024 at 07:41):

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

view this post on Zulip Anthony Bullard (Dec 08 2024 at 18:21):

Part 2 really makes you wish you read the requirements a few times

view this post on Zulip Anthony Bullard (Dec 08 2024 at 19:41):

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)

view this post on Zulip Anthony Bullard (Dec 08 2024 at 19:41):

https://github.com/gamebox/aoc-2024/tree/main/day7

view this post on Zulip Anthony Bullard (Dec 08 2024 at 19:42):

I know I could take a few different approaches to bail out of checking different combinations earlier

view this post on Zulip Anton (Dec 14 2024 at 15:14):

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