AoC 2024 Day 11: Exponential Growthinator

Source: Day 11: Plutonian Pebbles

Full solution for today (spoilers!).

Part 1

Given a sequence of values v_n, replace each value with the first matching rule:

  • if v = 0 -> 1
  • If v has an even number of digits, split it (so v = 8675 becomes [86, 75])
  • Otherwise, v -> v * 2024

Calculate how many elements are in the sequence after 25 iterations.

read more...


AoC 2024 Day 9: Defraginator

Source: Day 9: Disk Fragmenter

Full solution for today (spoilers!).

Part 1

Given a disk layout alternating between files and empty spaces, move all files as early on the disk is possible, splitting into multiple blocks. Return a checksum on the disk.

Alternating means: 23331 would mean a 2 block file, 3 empty, a 3 block file, 3 empty, and a 1 block file.

The checksum is the sum of file_id * block_index for all occupied blocks. File IDs are assigned sequentially on initial generation.

read more...


AoC 2022 Day 19: Blueprintinator

Source: Not Enough Minerals

Part 1

Given a series of given a series of blueprints, each of which gives instructions for how to build a single robot from a collection of materials that in turn will produce one of a given material per turn, determine the best order of builds to maximize your geode (the most valuable material) production for each blueprint given a time limit of 24 minutes.

read more...


AoC 2022 Day 17: Tetrisinator

Source: Pyroclastic Flow

Part 1

Simulate Tetris on a 7 wide board with a given (infinitely repeated) series of left and right inputs to be applied on each frame before dropping the block and a given (infinitely repeated) set of blocks. Once 2022 blocks have been dropped, what is the total height of the placed blocks?

read more...


AoC 2022 Day 16: Pressurinator

Source: Proboscidea Volcanium

Part 1

Given a graph of nodes, some of which have a pressure (per tick output value) and an agent that can move through the graph and activate specific nodes (so that they output their per tick value every future tick), what is the maximum total output possible in 30 steps?

read more...


Go is faster than Python? (an example parsing huge JSON logs)

Recently at work I came across a problem where I had to go through a year’s worth of logs and corelate two different fields across all of our requests. On the good side, we have the logs stored as JSON objects (archived from Datadog which collects them). On the down side… it’s kind of a huge amount of data. Not as much as I’ve dealt with at previous jobs/in some academic problems, but we’re still talking on the order of terabytes.

On one hand, write up a quick Python script, fire and forget. It takes maybe ten minutes to write the code and (for this specific example) half an hour to run it on the specific cloud instance the logs lived on. So we’ll start with that. But then I got thinking… Python is supposed to be super slow right? Can I do better?

(Note: This problem is mostly disk bound. So Python actually for the most part does just fine.)

read more...


AoC 2021 Day 23: Amphipodinator

Source: Amphipod

Part 1: Given 4 rooms full of amphipods with various energy costs for movement (a=1, b=10, c=100, d=1000) and a hallway, how much energy does it take (at minimum) to sort the amphipods into their own rooms with the following conditions:

read more...