Skip to content

Advent of Code 2025 Day 7: Laboratories

"""Advent of Code 2025: Day 7 - Laboratories"""

from advent import parse, grid_to_dict, defaultdict

grid = grid_to_dict(parse(7, list))
tachyons = defaultdict(int, {k: 1 for k, v in grid.items() if v == 'S'})
splits, total = 0, 0

while tachyons:
    for pos, n in list(tachyons.items()):
        del tachyons[pos]
        pos = pos + 1j

        match grid.get(pos):
            case '.':
                tachyons[pos] += n
            case '^':
                splits += 1
                tachyons[pos - 1] += n
                tachyons[pos + 1] += n
            case None:
                total += n

assert (splits, total) == (1662, 40941112789504)

Day 7

Solution

Today's solution ended up being pretty simple, so I'll just get straight into it.

I used my grid_to_dict() function to create a dict representation of the input, where '.' represents empty space, and '^' represents a splitter. I then seeded the tachyons dict with the single tachyon at the start.

The main loop will continue as long as there are tachyons to process. For each step, I process each tachyon as follows:

  • Remove it from the dict
  • Increment its position by 1j to move it down one row
  • There are 3 cases to consider for the new position:
    • If it's empty space, add the new tachyon
    • If it's a splitter:
      • Increment splits
      • Add two tachyons back, one to the left, one to the right
    • If it's not found, the tachyon has exited the building, so add the number of them to total

End