My solution for day 5. I've only completed Part 1 so far. It will be easy to do part 2 from here; but posting anyway for anyone who would like some ideas. I'll probably continue tomorrow evening. :smiley:
dang, i was hoping for some ideas to parse the input^^
I tried starting to implement the elm parser library, but it turns out making applicative parsers without currying is... not a thing i guess?
i mean i can start with the mapN
family of stuff. but i feel roc needs some new ideas for a nice parser. or I'm missing something and there already is one
i completely forgot that that's what the binding syntax sugar is for^^ well i guess i'll try and build a small parser
Here's my day 5. I really need to learn how to use the Parser
module. Also, List.walkWithIndex
might be useful in the stdlib, similar to Str.walkUtf8WithIndex
and List.mapWithIndex
.
wait, there's a Parser
module? I can't find it :sweat_smile:
There’s one in the examples dir
I'm working on adding support for packages, at which point that can become publishable as a standalone thing and you can import it from a URL alongside the platform
i'm assuming the url resolving thing works only for platforms?
but anyway, i'm trying to write my own small parser combinator as an exercise now, kinda stuck on the types :sweat_smile: (see this topic )
at the moment, yes - because we don't actually have a concept of packages yet :big_smile:
I ran into some strange bugs with the digit parser on this puzzle. I played with it a while and got it working by slowly building up the parser each step at a time and running a unit test to check it works. I couldn't figure out what the issue was, it was giving me a parsing error like "??????????".
I found a weird bug in my solution where I started getting duplicated crates out of nowhere. I ended up fixing it by recreating the target stack of crates with List.walk to [] List.append
. See the issue here.
Basically, I had to rewrite
newTo = List.concat to (List.reverse cratesToMove)
as
newTo = List.concat (List.walk to [] List.append) (List.reverse cratesToMove)
which should be equivalent.
I suspect there may be an issue in the internal implementation of List
.
@Gabriel Pickl I'll try not to cheat on future puzzles. :grinning: I took the lazy option here as I had burnt a bit of my evening time messing around with some other stuff. I've been enjoying learning about parsing with Roc.
Went with the same approach in my solution, maybe if we had transpose
I would've given parsing the first part a go too :big_smile:
I'll have to try out Parser
as well, maybe tomorrow!
My day 5: https://gist.github.com/ayazhafiz/9d315104502007f471b33ab8731be807. Im impressed by everyone that was able to parse the header of this day's input!
My day 5
It got pretty ugly in the end because I was juggling compiler crashes by trying to rewrite code in different ways :sweat_smile: but it's a parser I guess.
It's also really slow, mainly because the parser recreates strings a lot because there's no splitAt
or substring
in Str
Catching up!
Day5
Last updated: Jul 06 2025 at 12:14 UTC