Advent of Code 2023 - Day 2

This is a thread to discuss Day 2

It is VERY important NOT to write any public spoilers :slight_smile:
ALWAYS keep spoiler stuff hidden inside one of these


This text will be hidden

which you can obtain by clicking on the gear icon


Good luck :slight_smile:
FYI one of the features of Advent of Code is that we all get given different inputs so our answers will be different.
The examples are all the same but each of us gets different inputs for us to solve

I've started but I'm completely failing to parse the test input into something I can then start testing on :frowning:
[edit])09:00 UTC Had a coffee and 5 mins later managed to parse it into a useful shape :slight_smile:
[edit]09:17 UTC Success - works with test input - Fails on real data :frowning:
[edit]09:50 UTC Silly mistake using < instead of <= #LOL

Part 1 done at last :slight_smile:

And after breakfast - Part 2 (Which I found easy as my parsed input didn't need to be changed at all

Today's part 2 definitely felt easier than yesterdays after having finished part 1. I think the hardest part was to figure out how to parse all the data. Also the pipe block is awesome for this.

Part 1

Part 2

Very neat work :slight_smile:

For me parsing the input was the easiest part. The harder part was actually going through the parsed data and finding the max colors. Part 2 took me no time because I just had to change 2 things in my part 1 script.

Part 1

Part 2


Snap! Build Your Own Blocks

I'm pretty sure this is actually also the first time I've used the pipe block, and I find it really useful.


In game 1, three sets of cubes are revealed from the bag (and then put back again).

For me, It means:

  1. Get some cubes from the bag (set) a few times
  2. Put them back to bag
  3. Repeat for the next game

But the solution requires:

  1. Get some cubes from the bag (a set)
  2. Put them back to bag
  3. Repeat a few times
  4. Repeat for the next game

I like your solutions, they aren't trying to cram the solution in a giant HOF, instead it uses custom blocks (functions), and making it a bit more elegant. It's probably similar to how someone would do in a text based language (I don't think many people would write a solution like mine in a text based programming language, all because it's just a huge one liner).