The Problem
You're in a teleporter lab with a broken tachyon manifold. A tachyon beam enters at position S and travels downward through the manifold. When it hits a splitter (^), it stops and emits two new beams: one to the left and one to the right.
Summary
Part | Question | Strategy |
|---|---|---|
1 | How many times is the beam split? | Track unique beam positions, count splits |
2 | How many timelines exist at the end? | Track particle counts per position (many-worlds) |
Part 1: Count the Splits
Goal: Count how many times any tachyon beam is split by a ^ splitter.
The Key Insight: Beams Can Merge
Multiple beams can converge on the same column position. When two beams hit adjacent splitters, they might both emit into the same middle column:
Using a Set for beam positions handles this naturally - duplicates are ignored.
Part 2: Many-Worlds Interpretation 🌌
Goal: Instead of counting splits, count total timelines at the end.
Now we're dealing with quantum mechanics! Each split creates a fork in time - one timeline where the particle went left, another where it went right.
The Twist: Convergence Creates Parallel Histories
Two particles arriving at the same position are not the same timeline. They took different paths to get there!
The Solution: Count, Don't Just Track
Instead of a Set (which deduplicates), use a Map that tracks how many particles are at each position:
Why This Works
Part 1: We only care about where beams are (Set deduplicates)
Part 2: We care about how many particles (Map accumulates)
Each split doubles the number of timelines passing through that splitter. The final answer is the sum of all particle counts at the bottom of the manifold.
Performance
Part | Time |
|---|---|
Part 1 | 884µs |
Part 2 | 1.23ms |
Both parts are blazing fast because we process row-by-row, only tracking active positions rather than simulating every possible path explicitly.