A rewrite for Puzzle 17