http://qs321.pair.com?node_id=11117940


in reply to The 15 Puzzle

++ For your code. It's quite readable as well despite being dense IMHO.

About the number of permutations, rather than a loop wouldn't it be simpler to just have: @board[1,2] = @board[2,1] if $inversions %2; ?

Replies are listed 'Best First'.
Re^2: The 15 Puzzle
by msh210 (Monk) on Jun 14, 2020 at 08:37 UTC

    Good idea; thanks!

    $_="msh210";$"=$\;@_=@{[split//,uc]}[2,0];$_="@_$\1";$\=$/;++$_[0]for$...1;print lc substr crypt($_,"@_"),1,6