Source: Day 12: Garden Groups
Full solution for today (spoilers!).
Part 1
Given a
Grid
of regions, calculate the sum of the productperimeter * area
for each region.
Full solution for today (spoilers!).
Given a
Grid
of regions, calculate the sum of the productperimeter * area
for each region.
Full solution for today (spoilers!).
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 (sov = 8675
becomes[86, 75]
)- Otherwise,
v -> v * 2024
Calculate how many elements are in the sequence after 25 iterations.
Full solution for today (spoilers!).
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.
Given a series of given a series of
blueprints
, each of which gives instructions for how to build a singlerobot
from a collection ofmaterials
that in turn will produce one of a givenmaterial
per turn, determine the best order of builds to maximize yourgeode
(the most valuablematerial
) production for eachblueprint
given a time limit of24 minutes
.
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?
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?
Given a height map, find the shortest path between two points such that the path can descend any distance but can only climb by a maximum of 1.
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.)
w
, x
, y
, and z
) and instructions defined below. Find the largest 14 digit number with no 0 digits which result in z=0
.