Heuristic for puzzle 6.