Source: Day 18: RAM Run
Full solution for today (spoilers!).
Part 1
You are given a series of points on a
71x71grid. Taking only the first 1024 points, how long is the shortest path from(0, 0)to(70, 70)?
Full solution for today (spoilers!).
You are given a series of points on a
71x71grid. Taking only the first 1024 points, how long is the shortest path from(0, 0)to(70, 70)?
Full solution for today (spoilers!).
Implement a virtual machine. The machine will have 3 unbounded signed registers, 8 opcodes (see below), a variable parameter scheme (see below that). You will be given the initial values of the 3 registers and a program. Find the final output.
| Opcode | Instruction | Description | Notes |
|---|---|---|---|
| 0 | adv reg/val | A = A >> OP | |
| 1 | bxl val | B = B ^ OP | |
| 2 | bst reg/val | B = OP & 0b111 | |
| 3 | jnz val | If a =/= 0, jump to LIT | |
| 4 | bxc ignore | B = B ^ C | Still takes param, but ignores it |
| 5 | out reg/val | Output b | Only outputs lowest 3 bits |
| 6 | bdv reg/val | B = A >> OP | Same as adv but writes to b |
| 7 | cdv reg/val | C = A >> OP | Same as adv but writes to c |
For instructions that can take reg/val, 0 to 3 (inclusive) are treated as literal values, 4 is register A, 5 is B, 6, is C, and 7 is an error (should never happen).
For instructions that only take val, it’s always a literal value in the range 0 to 7 (inclusive).
Full solution for today (spoilers!).
Given a maze, what is the shortest path between
SandEwhere walking straight costs one and turning costs 1000.
Full solution for today (spoilers!).
Given a warehouse containing floors (
.), walls (#), boxes (O), and the player (@) plus a series of instructions^V<>, move the player according to the instructions, pushing boxes (which in turn can push more boxes).Calculate the sum of
y * 100 + xfor each box’s final position.
Full solution for today (spoilers!).
Given a series of robots defined with initial
positionandvelocityon a 101x103 toroidal grid, calculate where the robots will be after 100 iterations. Return the product of the number of robots in each quadrant of the final grid, ignoring the middle lines (since they’re odd).
Full solution for today (spoilers!).
Given Button A
(ax, ay), Button B(bx, by), and Prize(px, py); how many times must you press Button A (a) and Button B (b) to reach the Prize? Sum3a + bfor each machine that has a solution.
Full solution for today (spoilers!).
Given a
Gridof regions, calculate the sum of the productperimeter * areafor 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
vhas an even number of digits, split it (sov = 8675becomes[86, 75])- Otherwise,
v -> v * 2024Calculate how many elements are in the sequence after 25 iterations.
Full solution for today (spoilers!).
Given a heightmap (
0to9), for each0count how many9you can reach on paths that only ever increase height by exactly 1 at a time. Sum these values.
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:
23331would 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_indexfor all occupied blocks. File IDs are assigned sequentially on initial generation.