solves puzzles with backtracking, needs cleanup