AoC 2024 Day 22: Xorshiftinator

Source: Day 22: Monkey Market

Full solution for today (spoilers!).

Part 1

Implement a PRNG with the following update function:

  1. Multiply by 64, xor with the previous value, modulo 16777216
  2. Divide by 32, xor with the previous value (from step 1), modulo 16777216
  3. Multiply by 2048, xor with the previous value (from step 2), module 16777216

For each of a series of seeds, sum the 2000th generated number.

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 2024 Day 6: Wanderinator

Source: Day 6: Guard Gallivant

Full solution for today (spoilers!).

Part 1

You are given a grid of walls (#), floors (.), and a guard (^, initially facing up/north). The guard walks forward until they run into a wall at which point they turn right. How many tiles does the guard reach before leaving the map.

read more...


AoC 2022 Day 23: Elf Scattinator

Source: Unstable Diffusion

Part 1

Implement a cellular automaton with the following rules:

  • If you have no neighbors, don’t move (important, I forgot this one for a while)
  • Otherwise:
    • Calculate a potential move:
      • If you have no neighbors to the north, move north
      • If not, check likewise for south, then west, than east
    • If no other agent is moving to the same space, move to your potential move
    • Otherwise, don’t move
  • On each frame, rotate the order the directions are checked in (NSWE, SWEN, WENS, ENSW, NSWE, …)

read more...


AoC 2022 Day 22: Wonderator

Source: Monkey Map

Part 1

Given a map and a series of instructions formatted as distance + turn (L or R), find the final position. Any time you would walk off the edge of the map, wrap to the opposite edge.

read more...