2025(07): solve part 1

This commit is contained in:
2025-12-07 11:30:44 +01:00
parent e5041fc74b
commit 114aca009a
2 changed files with 138 additions and 0 deletions

View File

@ -139,3 +139,77 @@ This process continues until all of the tachyon beams reach a splitter or exit t
To repair the teleporter, you first need to understand the beam-splitting properties of the tachyon manifold. In this example, a tachyon beam is split a total of _`21`_ times. To repair the teleporter, you first need to understand the beam-splitting properties of the tachyon manifold. In this example, a tachyon beam is split a total of _`21`_ times.
Analyze your manifold diagram. _How many times will the beam be split?_ Analyze your manifold diagram. _How many times will the beam be split?_
### Part Two
With your analysis of the manifold complete, you begin fixing the teleporter. However, as you open the side of the teleporter to replace the broken manifold, you are surprised to discover that it isn't a classical tachyon manifold - it's a _<span title="Please disregard the wave interference patterns that would arise from the wave-particle duality of individual tachyon particles while repairing the manifold.">quantum</span> tachyon manifold_.
With a quantum tachyon manifold, only a _single tachyon particle_ is sent through the manifold. A tachyon particle takes _both_ the left and right path of each splitter encountered.
Since this is impossible, the manual recommends the many-worlds interpretation of quantum tachyon splitting: each time a particle reaches a splitter, it's actually _time itself_ which splits. In one timeline, the particle went left, and in the other timeline, the particle went right.
To fix the manifold, what you really need to know is the _number of timelines_ active after a single particle completes all of its possible journeys through the manifold.
In the above example, there are many timelines. For instance, there's the timeline where the particle always went left:
.......S.......
.......|.......
......|^.......
......|........
.....|^.^......
.....|.........
....|^.^.^.....
....|..........
...|^.^...^....
...|...........
..|^.^...^.^...
..|............
.|^...^.....^..
.|.............
|^.^.^.^.^...^.
|..............
Or, there's the timeline where the particle alternated going left and right at each splitter:
.......S.......
.......|.......
......|^.......
......|........
......^|^......
.......|.......
.....^|^.^.....
......|........
....^.^|..^....
.......|.......
...^.^.|.^.^...
.......|.......
..^...^|....^..
.......|.......
.^.^.^|^.^...^.
......|........
Or, there's the timeline where the particle ends up at the same point as the alternating timeline, but takes a totally different path to get there:
.......S.......
.......|.......
......|^.......
......|........
.....|^.^......
.....|.........
....|^.^.^.....
....|..........
....^|^...^....
.....|.........
...^.^|..^.^...
......|........
..^..|^.....^..
.....|.........
.^.^.^|^.^...^.
......|........
In this example, in total, the particle ends up on _`40`_ different timelines.
Apply the many-worlds interpretation of quantum tachyon splitting to your manifold diagram. _In total, how many different timelines would a single tachyon particle end up on?_

64
2025/07/part1.py Normal file
View File

@ -0,0 +1,64 @@
import numpy as np
debug = False
def load_diagram(filename: str):
# Read file as list of strings
with open(filename, "r") as fp:
data = fp.read().splitlines()
data_arr = np.array(data, dtype=str)\
.view("U1")\
.reshape((len(data), -1))
return data_arr
def print_diagram(diagram):
for line in diagram:
for char in line:
print(char, end="")
print()
def propagate_diagram(in_diagram, inplace=True):
diagram = in_diagram.copy() if not inplace else in_diagram
ylen = len(diagram)
# Find start location
y0 = 0
x0, = np.where(diagram[y0] == "S")[0]
# Emit starting beam
diagram[y0 + 1, x0] = "|"
splits_count = 0
# Propagate the beams, starting with y = 2, as the y = 1 layer has our first beam
for y in range(2, ylen):
for x in np.where((diagram[y] == "^")&(diagram[y - 1] == "|"))[0]:
# NOTE: I do not ever check whether carets are on the boundary.
diagram[y, (x - 1, x + 1)] = "|"
splits_count += 1
for x in np.where((diagram[y] == ".")&(diagram[y - 1] == "|"))[0]:
diagram[y, x] = "|"
if debug:
print_diagram(diagram)
print()
return splits_count
if __name__ == "__main__":
test_diagram = load_diagram("testinput")
assert propagate_diagram(test_diagram) == 21
diagram = load_diagram("input")
print(propagate_diagram(diagram))
def gnonkel(x, a):
if x:
a += 1
# -----
if x and y:
a+=1
elif x:
a+=1