added the logic to generate solvable puzzle