Stream: advent of code

Topic: Day 5


view this post on Zulip Luke Boswell (Dec 05 2022 at 10:30):

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:

view this post on Zulip Gabriel Pickl (Dec 05 2022 at 12:01):

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?

view this post on Zulip Gabriel Pickl (Dec 05 2022 at 12:02):

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

view this post on Zulip Gabriel Pickl (Dec 05 2022 at 13:05):

i completely forgot that that's what the binding syntax sugar is for^^ well i guess i'll try and build a small parser

view this post on Zulip Shritesh Bhattarai (Dec 05 2022 at 14:05):

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.

view this post on Zulip Gabriel Pickl (Dec 05 2022 at 14:30):

wait, there's a Parser module? I can't find it :sweat_smile:

view this post on Zulip Shritesh Bhattarai (Dec 05 2022 at 14:37):

There’s one in the examples dir

view this post on Zulip Richard Feldman (Dec 05 2022 at 14:41):

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

view this post on Zulip Gabriel Pickl (Dec 05 2022 at 14:50):

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 )

view this post on Zulip Richard Feldman (Dec 05 2022 at 14:51):

at the moment, yes - because we don't actually have a concept of packages yet :big_smile:

view this post on Zulip Luke Boswell (Dec 05 2022 at 19:30):

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 "??????????".

view this post on Zulip Héctor Ramón (Dec 05 2022 at 20:16):

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.

view this post on Zulip Héctor Ramón (Dec 05 2022 at 20:17):

I suspect there may be an issue in the internal implementation of List.

view this post on Zulip Luke Boswell (Dec 05 2022 at 21:49):

@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.

view this post on Zulip Máté Kaszás (Dec 05 2022 at 22:00):

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!

view this post on Zulip Ayaz Hafiz (Dec 06 2022 at 23:46):

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!

view this post on Zulip Gabriel Pickl (Dec 07 2022 at 00:08):

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

view this post on Zulip Logan Lowder (Dec 09 2022 at 04:23):

Catching up!
Day5


Last updated: Jul 06 2025 at 12:14 UTC