Stream: advent of code

Topic: Day 3


view this post on Zulip Luke Boswell (Dec 03 2022 at 06:36):

My day 3 solution. :big_smile:

view this post on Zulip Notification Bot (Dec 03 2022 at 06:42):

Luke Boswell has marked this topic as resolved.

view this post on Zulip Notification Bot (Dec 03 2022 at 06:43):

Luke Boswell has marked this topic as unresolved.

view this post on Zulip Shritesh Bhattarai (Dec 03 2022 at 07:09):

Here's my Day 3 . I'm happy with the solution but I found myself wishing Roc had these 3 2 things:

view this post on Zulip Andy Kluger (Dec 03 2022 at 07:34):

Another Day 3 solution. I know there's a way to do some nifty destructuring on the way from lists to function parameters...

view this post on Zulip JesterXL (Dec 03 2022 at 14:54):

Dude, I am learning waayyyyy more than I ever thought possible about basic adding/subtraction against various number types. I thought I was all ballin' when I understood the difference between / and // in Elm, but this U8 vs. U32 insanity is breaking my brain. I didn't realize math with these various number types was so dangerous.

view this post on Zulip JesterXL (Dec 03 2022 at 15:01):

Case in point "List.sum blows up" because U8 maxes at 256... like... man am I spoiled rotten in other languages.

view this post on Zulip Tommy Graves (Dec 03 2022 at 15:39):

Here's my day 3. I didn't know anything about scalar arithmetic so I went with a much dumber approach :rolling_on_the_floor_laughing:.

I was really surprised that Str.split "abc" "" returns ["abc"] and not ["a", "b", "c"]. I understand the reasoning, but I wish the compiler could blow up if you do Str.split with an empty separator. I'm not familiar with other languages that have the same behavior as Roc, but plenty (JS, Ruby, Rust) split the string into individual characters.

view this post on Zulip Brendan Hansknecht (Dec 03 2022 at 16:39):

That's an interesting note on Str.split. i guess we just have a few other methods that theoretically are for that. Like Str.toUtf8 or one of the methods that walks the code points/graphemes, but yeah...less clear

view this post on Zulip Ghislain (Dec 03 2022 at 17:26):

My solution

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

My solution!

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

ooh I love your recursive grouping strategy @Luke Boswell

view this post on Zulip Ayaz Hafiz (Dec 03 2022 at 18:16):

my day 3 - definitely looking forward to hash-based set/dict :nerd:

view this post on Zulip Luke Boswell (Dec 03 2022 at 18:58):

@Ayaz Hafiz the way you formatted that ifwas neat. I wonder if we could support that without braces for smaller use cases like this?

(if item >= 'a'
then item - 'a' + 1
else item - 'A' + 27)
|> Num.toU64

view this post on Zulip Richard Feldman (Dec 03 2022 at 19:01):

I actually want to support Num.toU64 if item >= 'a' then ... like CoffeeScript does!

view this post on Zulip Ayaz Hafiz (Dec 03 2022 at 19:04):

it might work without braces or richards way, i just didn’t try it

view this post on Zulip Sebastian Porto (Dec 03 2022 at 22:24):

Oh, I can do 'E' - 'A', that is pretty cool

view this post on Zulip JesterXL (Dec 03 2022 at 22:25):

My Day 3 (shrink took wayyy too long)

view this post on Zulip JesterXL (Dec 03 2022 at 22:25):

BTW, I left in all the compiler bugs in separate files in case you're interested in duplication compiler issues.


Last updated: Jul 06 2025 at 12:14 UTC