2025 Day 7: Laboratories

This time it was quite easy!

I made a boolean array for at which position a light ray is and the first line gave me my “starting position”

The learn ada website had the exact example I needed to get all instances of “^” See: Standard library: Strings - learn.adacore.com
For each output position I check if in that column has a beam and changed it accordingly.

And I really like this line in part2. Told it to a friend without context. :laughing: (Still have to do part 2 tho…)

Apply the many-worlds interpretation of quantum tachyon splitting to your manifold diagram.

2 Likes

Very cool and simple solution!

I overthought part 1 and used dfs but it’s clearly not the right way to do this.

1 Like

For part 1 I did an array of booleans. I read each line one at a time, set the boolean flag when I saw S, and when I saw ^ I cleared the boolean for the ^ and set it for the two adjacent ones and incremented the split count.For part 2, I had an array of 64-bit naturals, again, line by line, when I saw S, I set parent count to 1, and when I saw ^, I added the parent count at its column to the ones to its immediate left and right, and then set its count to 0. At the end, I just had to sum the counts.

2 Likes

Today was fun! At first I thought it would be breadth-first search, so I overengineered both parts to use sets, vectors, etc.; i.e., I was tracking paths in some detail I hit a combinatorial explosion in Part 2 and crashed my computer (ssd started thrashing (?) because I hit too many timelines: my answer is greater than 10^15!!! :astonished_face:) so I worked through the example by hand a couple of times until I eventually hit upon the same solution as @wutka.

2 Likes

Quick update: porting the solution to HAC, which lacks Ada’s containers, forced me to re-think my answer to Part 1. The resulting algorithm is much cleaner.

1 Like