• Home
  • About
    • 康青旭 - Germán Caggianese photo

      康青旭 - Germán Caggianese

      Refactoring entropy in my Mind

    • Learn More
    • Email
    • Instagram
    • Github
    • Codeberg   Codeberg
  • All Posts
  • Projects
  • Areas
  • Resources

Advent of Code 2025 - Day 7

07 Jan 2026

Reading time ~4 minutes

“Suddenly, you find yourself in an unfamiliar room! The room has no doors”

Github: GCaggianese/AoC-2025/D7

Puzzle Day 7: Laboratories

Part One

Process top-to-bottom. For each cell a_{i,j}:

  • . → do nothing
  • S or | → look at $a_{i+1,j}$ (cell below):
    • if . → change it to |
    • if ^ → $a_{i+1,j-1}$ and $a_{i+1,j+1}$ become |
      • Important: mark ^ as used Count how many ^ splitters are marked as used.

Part Two

Count all possible timelines when ^ splits go one direction at a time.

For each cell a_{i,j}:

  • col >= cols → return 1 (completed path)
  • row >= rows → return 1 (reached bottom)
  • ^ at $a_{r,col}$ → recurse:
    • countPaths(r+1, col-1) + countPaths(r+1, col+1)
    • if col == 0 → left branch returns 1 (off-grid = completed)

Example

.S.        .S.   .S.
...   →    .|.   .|.
.^.        |^.   .^|
...        |..   ..|
..^        |.^   .|^

Left path: 1 (reaches bottom) Right path: hits ^ at (4,2) → splits again → 2 Total: 3 timelines

Optimization

Memoization via HashMap(State, usize) where State = {row, col}. Avoids recalculating paths from the same position.

Unless stated otherwise, the content of the website is licensed under a Creative Commons Attribution 4.0 International license.

© 2025 Germán Caggianese(康青旭)