Solve a Hidato puzzle: Difference between revisions
→{{header|Julia}}
Line 1,906:
=={{header|Julia}}==
This solution utilizes a
<lang julia>module Hidato
Line 1,937:
end
function hidatosolve(board, maxmoves, movematrix, fixed, row, col, sought
if sought > maxmoves
return true
Line 1,943:
return false
end
backnum = board[row, col] == sought ? sought : 0
board[row, col] = sought # try board with this cell set to next number
for move in movematrix
i, j = row + move[1], col + move[2]
if (0 < i <= size(board)[1]) && (0 < j <= size(board)[2]) &&
hidatosolve(board, maxmoves, movematrix, fixed, i, j, sought + 1
return true
end
Line 1,983 ⟶ 1,979:
board, maxmoves, fixed, starts = hidatoconfigure(hidat)
printboard(board)
hidatosolve(board, maxmoves, kingmoves, fixed, starts[1][1], starts[1][2]
printboard(board)
</lang>{{output}}<pre>
|