4 ms·
Yeah, I solved it in a way that's almost instantaneous (0.060s after deciding not to use numpy). First I generate the list of all possible solution sequences (
by scaramanga 6y ago
Yeah, I solved it in a way that's almost instantaneous (0.060s after deciding not to use numpy).
First I generate the list of all possible solution sequences (82 in your example) ordering them from shortest to longest.
Then I search for that shorter list in the matrix.
Enjoy: https://gist.github.com/giannitedesco/cc46c347c0337b10e24d009814509438 https://gist.github.com/giannitedesco/cc46c347c0337b10e24d00...
- scaramanga 6y agoThis doesn't actually work if there's no immediate solution and you have to pick duds before you can make progress. But I think the way to brute force that is by breadth-first search for dud-prefixes and ending with the specific sequence searches. For now I fixed it by just assuming we can always solve the puzzle with a single "leap of faith" pick at the start (seems so from my own anecdotal experience?) :) Note that the full puzzle isn't really solvable off-line (edit: I mean in a fully general sense) because of the case where you switch from solving one sequence to another and an extra prefix gets added by the game as a punishment!