ソースこれな
https://rosettacode.org/wiki/15_Puzzle_Game