Solve a Holy Knight's tour: Difference between revisions
Content added Content deleted
(Added Go) |
|||
Line 2,453: | Line 2,453: | ||
[Finished in 7.2s]</pre> |
[Finished in 7.2s]</pre> |
||
=={{header|Julia}}== |
|||
# Uses the Hidato puzzle solver module, which has its source code listed [[Solve_a_Hidato_puzzle#Julia | here]] in the Hadato task. |
|||
<lang julia>using .Hidato # Note that the . here means to look locally for the module rather than in the libraries |
|||
const holyknight = """ |
|||
. 0 0 0 . . . . |
|||
. 0 . 0 0 . . . |
|||
. 0 0 0 0 0 0 0 |
|||
0 0 0 . . 0 . 0 |
|||
0 . 0 . . 0 0 0 |
|||
1 0 0 0 0 0 0 . |
|||
. . 0 0 . 0 . . |
|||
. . . 0 0 0 . . """ |
|||
const knightmoves = [[-2, -1], [-2, 1], [-1, -2], [-1, 2], [1, -2], [1, 2], [2, -1], [2, 1]] |
|||
board, empties, fixed, starts = hidatoconfigure(holyknight) |
|||
printboard(board, " 0", " ") |
|||
hidatosolve(board, knightmoves, fixed, starts[1][1], starts[1][2], 1, 1, empties + length(fixed)) |
|||
printboard(board) |
|||
</lang>{{output}}<pre> |
|||
0 0 0 |
|||
0 0 0 |
|||
0 0 0 0 0 0 0 |
|||
0 0 0 0 0 |
|||
0 0 0 0 0 |
|||
1 0 0 0 0 0 0 |
|||
0 0 0 |
|||
0 0 0 |
|||
7 4 17 |
|||
16 8 5 |
|||
9 6 3 18 25 20 23 |
|||
31 2 15 22 26 |
|||
10 30 19 24 21 |
|||
1 32 11 14 29 34 27 |
|||
36 33 13 |
|||
12 35 28 |
|||
</pre> |
|||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |