Analyze your manifold diagram.
Part 1
Provided the following diagram with the beam moving down from the S, how many times will the beam be split?
.......S.......
...............
.......^.......
...............
......^.^......
...............
.....^.^.^.....
...............
....^.^...^....
...............
...^.^...^.^...
...............
..^...^.....^..
...............
.^.^.^.^.^...^.
...............
I bruteforced this one by validating an incoming beam above each of the splitters and counting that value. I generated the entire diagram and then rewalked each value to complete the count.
Part 2
For this part we needed to calculate the total number of possible paths. I’m creating a grid with path counts and increasing the count every time the splitter is encountered.
for i in Lines[1:]:
for col in range(len(curr)):
if curr[col] > 0 and i[col] == '^':
p2 += curr[col]
curr[col-1] += curr[col]
curr[col+1] += curr[col]
curr[col] = 0
I spent a lot of time doing something similar to this but needed some help switching the grid to a count versus tallying things in separate variables. This is a much cleaner approach which I like.
There were some fun animations of this happening in the subreddit.
Comments
This blog uses a Mastodon and webmentions for comments. You can comment by replying on Mastodon/ActivityPub/Fediverse account or webmention.