16 puzzle game: Difference between revisions

Content added Content deleted
(julia example)
Line 533: Line 533:


inorder = string.(reshape(1:bsize*bsize, bsize, bsize))
inorder = string.(reshape(1:bsize*bsize, bsize, bsize))
shufflepuzzle(puzz) = shuffle(puzz)
puzzle = shuffle(inorder)
puzzle = shufflepuzzle(inorder)
rotatecol(puzzle, col, n) = puzzle[:, col] .= circshift(puzzle[:, col], n)
rotatecol(puzzle, col, n) = puzzle[:, col] .= circshift(puzzle[:, col], n)
rotaterow(puzzle, row, n) = puzzle[row, :] .= circshift(puzzle[row, :], n)
rotaterow(puzzle, row, n) = puzzle[row, :] .= circshift(puzzle[row, :], n)
Line 609: Line 608:


function initialize!(w)
function initialize!(w)
puzzle = shufflepuzzle(inorder)
puzzle = shuffle(inorder)
won = false
won = false
update!()
update!()
Line 626: Line 625:
puzzle16app(4)
puzzle16app(4)
</lang>
</lang>



=={{header|Phix}}==
=={{header|Phix}}==