Stream: advent of code

Topic: Day 1


view this post on Zulip Ghislain (Dec 01 2022 at 12:33):

I launch the feedback for Day 1 of AoC! (my solution)

view this post on Zulip Fabian Schmalzried (Dec 01 2022 at 13:28):

Not sure If this is a good way for handling task failures but I just did |> Task.onFail (\_ -> Task.succeed {}). It was my first actual roc programm today!

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

Friendship ended with Result.withDefault, now crash is my best friend: my solution.

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 14:08):

list pattern matching :heart_eyes:

view this post on Zulip Srinivas Rao-Mouw (Dec 01 2022 at 17:44):

hey y'all! excited to Roc with everybody!!!

view this post on Zulip Srinivas Rao-Mouw (Dec 01 2022 at 17:45):

I have a silly question -- how do you parse a file :sweat_smile: ? I currently just pasted the input into my main.roc file

view this post on Zulip Srinivas Rao-Mouw (Dec 01 2022 at 17:46):

Shritesh Bhattarai said:

Friendship ended with Result.withDefault, now crash is my best friend: my solution.

oooh I'm stealing this parsing logic, thanks @Shritesh Bhattarai

view this post on Zulip Ayaz Hafiz (Dec 01 2022 at 17:47):

There are some more examples of using the CLI platform to work with files in this example: https://github.com/roc-lang/roc/blob/2a27d3c05f7974adf87e782704eab8d43c80652e/examples/cli/file.roc

view this post on Zulip Brendan Hansknecht (Dec 01 2022 at 17:49):

I always did it manual with string splitting and such. Some people use proper parser combinators.

You can find some examples from last years problems here if you need some code to look at for parsing this way: https://github.com/bhansconnect/roc-aoc-2021

Note: may not compile anymore without some minor updates and tweaks due to changes to roc and the cli platform.

view this post on Zulip Srinivas Rao-Mouw (Dec 01 2022 at 17:56):

here's my solution

view this post on Zulip Luke Boswell (Dec 01 2022 at 19:40):

My solution for Part 1

I've playing around with parsers and wanted to practice, so my answer is probably overkill for this first one. I should eventually be able to simplify these parsers a lot as my understanding grows I think. My plan is to have a base that should scale a bit nicer into the later AoC challenges. :grinning_face_with_smiling_eyes:

view this post on Zulip Bartek Ciszkowski (Dec 01 2022 at 22:52):

Srinivas Rao-Mouw said:

Shritesh Bhattarai said:

Friendship ended with Result.withDefault, now crash is my best friend: my solution.

oooh I'm stealing this parsing logic, thanks Shritesh Bhattarai

Interestingly, this does not run for me on macOS M1. I was also attempting Day 1 using Roc but I might not be on the ideal platform for such tinkering ..

(using a main.roc with the linked code)

❯ roc
The program crashed with:

    Failed to read and parse input

Here is the call stack that led to the crash:

    roc.panic
    app.(anonymous function)
    Task.(anonymous function)
    rust.main

Can I adjust Task.onFail to provide the reason for the crash?

view this post on Zulip Andy Kluger (Dec 02 2022 at 05:35):

I'm excited to have muddled through the first one with good help from friendly folks here

EDIT: Ha, ah, that was just part 1

view this post on Zulip Tommy Graves (Dec 02 2022 at 05:38):

A little late to the party, but here's my day 1

view this post on Zulip Ian Erik Varatalu (Dec 03 2022 at 03:30):

I also finally got day 1 completed, here's another solution

view this post on Zulip Logan Lowder (Dec 03 2022 at 21:23):

Also catching up! My solution (first roc program!)

view this post on Zulip Logan Lowder (Dec 03 2022 at 21:24):

Thanks to everyone else sharing! Getting some good ideas for how to improve

view this post on Zulip Johannes (Dec 11 2022 at 20:09):

Day 01 – my first Roc program, so happy I could figure it out...! :innocent:

Setting up the 'boilerplate' code to make the tasks work (like trying to understand that main has the type of 'Task') was the most difficult part for me.


Last updated: Jul 06 2025 at 12:14 UTC