Got my lousy day 4 up. It breaks roc format
, so you know it's good.
My day 4 solution. :D
Hit a miscompilation(IIUC) bug trying out today's problem https://github.com/roc-lang/roc/issues/4677
It's been interesting to look at others' solutions, so I'll share mine as well ^^
Day 4, I completely missed that overlaps count as intersects in Part 2
My solution! my parsing logic is so messy, curious how others did it.
I think all of us were like "Just give me a record with {start, end}, kthx" haha
My solution. Today was a real doozy, not because it was a difficult problem but I kept on getting incorrect results and things kept on getting worse from there: even a simple List.map
wasn't working as expected. I literally believed at one point that my machine was broken and spun up a Linux VM to repro. Turns out:
dbg
should not be trusted at all: https://github.com/roc-lang/roc/issues/4677#issuecomment-1336486960List.range
is broken: https://github.com/roc-lang/roc/issues/4196Wow, smart and concise @Shritesh Bhattarai ! :star_struck:
Here's mine, looking forward to the tuple feature!
ironically I think the most bugs people have run into with advent of code this year has been with a feature literally called "debug" :sweat_smile:
the one I hit the most is misplacing a comma and hitting a TODO for unimplemented tuples
caught up to day 4 today! part 1 part 2
T a b
tuples. i couldn't put them in type annotation like line : Parser (List U8) (T Range Range)
. Roc would tell me "Nothing is named T
in this scope."I caught up too!
This solution is the one I'm most proud of so far. Day4
This time I tried out writing just type annotations with no implementations like Richard mentioned in a talk I saw recently. Worked really nicely!
Juliano said:
- struggled and gave up using the fake
T a b
tuples. i couldn't put them in type annotation likeline : Parser (List U8) (T Range Range)
. Roc would tell me "Nothing is namedT
in this scope."
I think line : Parser (List U8) [T Range Range]
should do the trick there, because T
is just a tag. Or, if you want to create an alias like Ranges : [T Range Range]
, you can do Parser (List U8) Ranges
Last updated: Jul 06 2025 at 12:14 UTC