My actual puzzle solution was such a hack that writing the visualization was a more difficult puzzle than the puzzle itself. =)