Aaron's Page

This is where I post about what I'm working on.

--- Day 18: Snailfish ---

or..

I should have just committed to using strings from the get go.

one art please

Part 1

Python

I'm the reverse of what AoC expects for coding time. I have no real time for focus on the weekend since there's no daycare! I first got the idea that I should parse the string into a list, then a list of tuples containing the depth and value. This actually worked pretty well until I got the very end and needed the "pairs" to calculate a score. I spent the next day off and on tinkering with string parsing until my abomination would produce the right value.

Go

Still catching up

Part 2

Python

This was fairly easy thanks to reading a bit and the itertools.combinations function. I just had to create the "pairs" then mirror them to create the full list since:

Note that snailfish addition is not commutative - that is, x + y and y + x can produce different results.

Which resulted in my mutated setup function:

>def setupdata(data) -> list:
    data = data.split("\n")
    d = list(itertools.combinations(data, 2))
    d += [(x[1], x[0])for x in d]
    return d

I'm doing my best to use type hints on all of my functions.

Go

We'll see.

<< - Table of Contents - >>