Solving Rakatan Temple Catacomb Puzzle
I have a habit of ignoring datapad, which in K1 has negligible consequences since one can get most things right through trial and error. The one thing that I could not figure out through trial and error is this frigging puzzle, so I wrote some code to solve it instead ;). I was able to eliminate repetition movements (i.e. moving back and forth between two tiles) for the computation, but I'm sure it could be optimized further.
Temple Catacomb Puzzle is undoubtedly the most difficult puzzle in the game where you need to flip the colour of all tiles on a 3 by 3 grid. You are only allowed to move vertically, and horizontally (not diagonally, for now). Each time you touch upon a tile, the colour of the tile and its surrounding tiles are flipped. For our purpose, I'll label the tiles from coordinate (0,0) to (2,2), which represents the bottom left and upper right tile, respectively. This means the 'H' path suggested on the Data Pad leads to 2 unique paths:
(0, 0)->(0, 1)->(0, 2)->(0, 1)->(1, 1)->(2, 1)->(2, 2)->(2, 1)->(2, 0)(0, 0)->(0, 1)->(0, 2)->(0, 1)->(1, 1)->(2, 1)->(2, 0)->(2, 1)->(2, 2)
Surprisingly, if we limit the number of steps to 12, then these 2 paths are the only valid and unique ones, which require 9 steps. If we limit the number of steps to 16, then we get 166 unique paths to solve the puzzle! Below are a few examples (13 steps):
(0, 0)->(0, 1)->(1, 1)->(0, 1)->(0, 2)->(1, 2)->(2, 2)->(2, 1)->(1, 1)->(1, 2)->(1, 1)->(2, 1)->(2, 0)(0, 0)->(0, 1)->(1, 1)->(2, 1)->(2, 0)->(2, 1)->(2, 2)->(1, 2)->(0, 2)->(1, 2)->(1, 1)->(0, 1)->(1, 1)(0, 0)->(0, 1)->(0, 2)->(0, 1)->(0, 0)->(1, 0)->(2, 0)->(2, 1)->(2, 2)->(2, 1)->(1, 1)->(1, 0)->(0, 0)
If we set step limit to 17, then there are 8887 unique paths!!! Below are a couple of examples:
(0, 0)->(0, 1)->(1, 1)->(0, 1)->(0, 0)->(1, 0)->(0, 0)->(0, 1)->(1, 1)->(0, 1)->(0, 2)->(1, 2)->(2, 2)->(1, 2)->(1, 1)->(1, 0)->(2, 0)(0, 0)->(0, 1)->(1, 1)->(0, 1)->(0, 2)->(1, 2)->(1, 1)->(2, 1)->(1, 1)->(1, 2)->(1, 1)->(2, 1)->(2, 0)->(2, 1)->(1, 1)->(2, 1)->(2, 2)
If we introduce diagonal movement, however, there are 33 unique paths that only requires 9 steps. One example of such paths is: (0, 0)->(0, 1)->(0, 2)->(1, 1)->(0, 1)->(1, 1)->(2, 2)->(1, 1)->(2, 0). The number of viable solutions explodes as the step limit increases, and there should be an infinite number of solutions to such a puzzle.
Moral of the story: always read datapads, don't waste half an hour on this code and another half an hour on this post like myself!!
Posted Jul 15, 2019, 5:45 PM UTC
The letter "H" is your friend. 😉
Too true!