2021-12-25 - Sea Cucumber
Day 25 puzzle input is a grid showing the position and direction that some sea cucumbers are (mine is here) - where
. is an empty space,
> is an east-facing sea cucumber,
v is a south-facing sea cucumber. There are some rules that govern how they can move around the grid (east-facing move before south-facing, if you go off the bottom or right of the grid you wrap around). Part 1 involves finding how many "steps" it takes to reach a state where no cucumber can move. There is no Part 2.
2021-12-24 - Arithmetic Logic Unit
NOTE: Abject failure on this one. I'm gonna come back and kick its ass in a couple of days :D
2021-12-23 - Amphipod
Day 23 puzzle input is the position of some amphipods inside some rooms and a little hallway connecting them all. Mine is here. Part 1 involves using some rules about where and when they can be moved to determine how many moves are required to return them to their proper room. Part 2 involves modifying the input by adding a couple more amphipods per-room and doing the same calculation.
Verdict: got the result in the end but P2's test eludes me, it's like 4k lower than expected :-/ Not super happy with the end result:
- there's a lot of repeated code (like inside
- I don't parse the input, I just initialize a
- I store hallway places as
listand rooms as a
dict, and serialize to string when pushing the state to the priority queue and deserialize back when working on it. But actually the serialized representation is pretty workable as well as being compact + usable in the heapq. It's probably possible to make a couple of changes to eliminate the serialize/deserialize
- There are plenty of optimizations to be had.
- No real need for two separate "completed" funcs tbh
Will come back to this one again.
2021-12-22 - Reactor Reboot
Day 22 puzzle input defines some cubes which specify whether a position is "on" or "off" (mine is here). Part 1 involves finding how many "on" positions are within a small region. Part 2 involves finding how many "on" positions exist everywhere in the system.
The famous Tweet applies here:
Me sowing: Haha fuck yeah!!! Yes!!
Me reaping: Well this fucking sucks. What the fuck.
I reaped in Part 2 what I sowed by brute-forcing Part 1 then frolicking around all day while the other Logex guys were actually solving the problem.
2021-12-21 - Dirac Dice
Day 21 puzzle input is just two players and their starting positions for a game involving dice (mine is here). Part 1 involves playing the game to completion and multiplying the score of the losing player by the number of dice rolls. Part 2 involves doing the same but with a special "quantum" die that simulates ever possible dice outcome. This was a weird one.
2021-12-20 - Trench Map
Day 20 puzzle input is the input parameter for an image enhancement algorithm and a small 5x5 image to be enhanced (mine is here). Part 1 involves implementing the defined enhancement algorithm, applying it two times and finding the number of
# pixels. Part 2 involves doing the same but applying the algorithm 50 times.
2021-12-19 - Beacon Scanner
Day 19 puzzle input is a collection of scanners and the relative 3D positions of scanners they can see (mine is here). Part 1 involves translating and rotating these to find how the scanners all fit together and finding the number of beacons overall. Part 2 involves finding the maximum manhattan distance between any two scanners.
A warning to anyone who wants to look at or enjoy the code contained within:
This place is not a place of honor... no highly esteemed deed is commemorated here... nothing valued is here. What is here was dangerous and repulsive to us. This message is a warning about danger.
2021-12-18 - Snailfish
Day 18 puzzle input is a bunch of numbers defined as nested set of pairs inside square brackets (mine is here). Part 1 involves interpreting these as an equation and finding the sum. Part 2 involves finding which two numbers sum to the largest value.
2021-12-17 - Trick Shot
Day 17 puzzle input is a couple of x/y coordinate range pairs that describe a target box (mine is here). Part 1 involves calculating the highest
y position you'd of a probe you chuck at this co-ordinate (there are some weird deceleration calcs given the initial x/y velocities you chuck the probe at). Part 2 involves finding the number of possible ways you can chuck the probe so that it hits the target range.
2021-12-16 - Packet Decoder
Day 16 puzzle input is a sequence of hex digits which represent a nested structure of packets (mine is here). Part 1 involves doing parsing and expanding the nested packets, retrieving the "version" and summing this for each packet. Part 2 involves fully parsing the packets, interpreting them as mathematical operators finding the value of the calculation the input represents.
2021-12-15 - Chiton
Day 15 puzzle input is a 2D grid representing a cave with digits representing various "risk" values for each tile in a cave (mine is here). Part 1 involves finding a path through this from top-left to bottom-right with the lowest total "risk". Part 2 involves the same but for a grid that is 5x the size (right and down) and kinda repeated with a slight alteration.
2021-12-14 - Extended Polymerization
Day 14 puzzle input is a description of a "polymer" (a string) and a number of transforms (a pair of polymer elements, and a new element that would be inserted between them after it is applied to the polymer) - mine is here. Part 1 involves transforming the polymer
10 times, finding the most and least common elements and subtracting them. Part 2 involves the same but
2021-12-13 - Transparent Origami
Day 13 puzzle input consists of some co-ordinates of dots on a piece of transparent paper, and some instructions describing a sequence of folds to perform (mine is here). Part 1 involves determining the number of dots which are visible after performing the first fold. Part 2 involves following all the folds and determining a code from the resulting dot pattern.
2021-12-12 - Passage Pathing
Day 12 puzzle input describes a collection of named caves (lower-case = small caves, and upper-case = big caves) and how they are connected (mine is here). Part 1 involves finding the number of possible paths from "start" to "end" with the restriction that you can only visit small caves once. Part 2 similarly involves finding the number of possible paths, but now you can visit one small cave twice in each run.
2021-12-11 - Dumbo Octopus
Day 11 puzzle input is a grid of integers representing "energy level" of dumbo octopuses (mine is here). Over discrete time steps their energy increments, and if at any time it exceeds
9 then this increases to neighbouring octopuses' energy levels also (and if they exceed 9 this gives a boost to neighbouring octopuses and so on, it cascades). Part 1 involves finding how many times an octopus crossed that energy level from
10 (i.e. it "flashes") over 100 time steps. Part 2 involves finding the number of time steps that pass before all octopuses "flash" in one particular step.
2021-12-10 - Syntax Scoring
Day 10 puzzle input is a sequence of lines comprising different types of brackets - parentheses, curly braces, square brackets and curly braces (mine is here). Part 1 involves validating whether the closing bracket for each opening one - if there is an error we return report an error score and collect the total. Part 2 involves finding the valid sequences, determining the string that would complete each one, calculating a score for this additional string, sorting these scores and taking the middle one.
2021-12-09 - Smoke Basin
Day 9 puzzle input is a square grid of integers (mine is here) representing heights of a floor. Part 1 involves finding the sum of lowest points plus 1. Part 2 involves finding the "basins" - the areas surrounding each lowest point which are higher than it (and the points higher than that, and so on) excluding points of height 9.
2021-12-08 - Seven Segment Search
Day 8 puzzle input is a collection of:
1. patterns that represent all digits
9 in a random order in a 7-digit display followed by a pipe ...
2. then a pattern representing four digits that comprise an output
The segments in the display are addressed as
g and the digits are constructed like the below:
0: 1: 2: 3: 4: aaaa .... aaaa aaaa .... b c . c . c . c b c b c . c . c . c b c .... .... dddd dddd dddd e f . f e . . f . f e f . f e . . f . f gggg .... gggg gggg .... 5: 6: 7: 8: 9: aaaa aaaa aaaa aaaa aaaa b . b . . c b c b c b . b . . c b c b c dddd dddd .... dddd dddd . f e f . f e f . f . f e f . f e f . f gggg gggg .... gggg gggg
My puzzle input is here. Part 1 involves finding the number of times the digits
8 (which are easy and unambiguous to spot) appear in the output. Part 2 involves finding a way to decode each line sum the resulting outputs.
2021-12-07 - The Treachery of Whales
Day 7 puzzle input is a sequence of comma-separated integers representing positions of some crab submarines (mine is here) which can only move along one dimension. Part 1 involves finding the fewest amount of total "fuel" (expended at a rate of one fuel per step) required to move crabs to the same position. Part 2 involves doing this same calculation, but using a different calculation (one fuel expended on first step, two fuel on the second, three on the third, etc).
2021-12-06 - Lanternfish
Day 6 puzzle input is a sequence of integers representing the ages of lanternfish (mine is here). Part 1 involves following the lifecycle of these lanternfish over 80 days, where every 7 days lanternfish will spawn a new one (so a lanternfish that starts with age
4 will produce a new fish in
4 days, then another
7 days after that). Part 2 involves doing this over 256 days.
2021-12-05 - Hydrothermal Venture
Day 5 puzzle input is a list of co-ordinate pairs that represent lines (mine is here). Part 1 involves finding how many points the horizontal and vertical lines cross at least twice. Part 2 involves the same but including diagonal lines too.
2021-12-04 - Giant Squid
Day 4 puzzle input is a sequence of comma-separated numbers representing the order that bingo balls are drawn, followed by a number of bingo cards (mine is here). Part 1 involves playing through the bingo game and finding the first card to have a complete row or column. Part 2 involves finding the very last one.
2021-12-03 - Binary Diagnostic
Day 3 puzzle input is a list of binary numbers (mine is here). Part 1 involves finding the most and common values in each bit position and using these to produce "gamma" and "epsilon" values, and finding the product of these. Part 2 involves combing through the list of binary numbers, finding the most/least common digit in each position and repeatedly filtering this to produce "oxygen generator rating" (from the most common) and the "co2 scrubber rating" (from the least common) - and again finding the product of these two numbers.
2021-12-02 - Dive!
Day 2 puzzle input is a sequence of commands (
up n or
down n) which manipulate a submarine's position (mine is here). Part 1 involves interpreting these as directly adjusting the submarine's
depth - the answer being the product of these. Part 2 is the same but with
down n interpreted as adjusting a parameter
aim and each
forward movement both adjusting the current horizontal position (by
n) and the current
n * aim). The answer was still the product of
2021-12-01 - Sonar Sweep
Day 1 puzzle input is a list of integers which represent a sequence of depth readings (mine is here). Part 1 involves counting how many individual readings were larger than the previous one. Part 2 is the exact same but for the sum of a "depth window" of the previous three readings.