How to resolve the algorithm Solve a Hopido puzzle step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Solve a Hopido puzzle step by step in the zkl programming language

Table of Contents

Problem Statement

Hopido puzzles are similar to Hidato. The most important difference is that the only moves allowed are: hop over one tile diagonally; and over two tiles horizontally and vertically. It should be possible to start anywhere in the path, the end point isn't indicated and there are no intermediate clues. Hopido Design Post Mortem contains the following: "Big puzzles represented another problem. Up until quite late in the project our puzzle solver was painfully slow with most puzzles above 7×7 tiles. Testing the solution from each starting point could take hours. If the tile layout was changed even a little, the whole puzzle had to be tested again. We were just about to give up the biggest puzzles entirely when our programmer suddenly came up with a magical algorithm that cut the testing process down to only minutes. Hooray!" Knowing the kindness in the heart of every contributor to Rosetta Code, I know that we shall feel that as an act of humanity we must solve these puzzles for them in let's say milliseconds. Example: Extra credits are available for other interesting designs.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Solve a Hopido puzzle step by step in the zkl programming language

Source code in the zkl programming language

hi:=  // 0==empty cell, X==not a cell
#<<<
"   X 0 0 X 0 0 X
    0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    X 0 0 0 0 0 X
    X X 0 0 0 X X
    X X X 0 X X X";
#<<<
adjacent:=T( T(-3,0),
      T(-2,-2),   T(-2,2),
    T(0,-3),         T(0,3),
       T(2,-2),   T(2,2),
             T(3,0) );

puzzle:=Puzzle(hi,adjacent);
puzzle.print_board();
puzzle.solve();
println();
puzzle.print_board();
println();

  

You may also check:How to resolve the algorithm Sort disjoint sublist step by step in the Julia programming language
You may also check:How to resolve the algorithm Loops/With multiple ranges step by step in the Wren programming language
You may also check:How to resolve the algorithm Zig-zag matrix step by step in the Ceylon programming language
You may also check:How to resolve the algorithm Curzon numbers step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Zero to the zero power step by step in the Lua programming language