Hidato (sometimes referred to as Hidoku or Numbersnake) is a logic puzzle game that appears in many newspapers (e.g., Seattle Times), books (e.g., Hidato: 200 Pure Logic Puzzles, and Web sites (e.g., hidato.com). The goal of Hidato is to fill a grid with consecutive numbers that connect horizontally, vertically or diagonally. For example:
Note that grid need not be square and may even have holes. Some of the cells are filled in at the start, and it is up to the player to fill in the remaining cells so that the numbers from 1 to the maximum (here, 79) are connected.
For a person, solving a Hidato puzzle requires complex and careful logical reasoning. However, it turns out that even the most challenging Hidato puzzles can be easily solved by a computer using recursive backtracking. You are to write such a program. Your program should prompt the user for a file that contains the specifications for a puzzle. The first line of the puzzle file should specify the number of rows and columns in the grid. The contents of the grid should be specified next, with double-asterisks representing gaps in the grid and double-dashes representing blank cells. For example, the Hidato grid shown above would be represented as:
Assuming a solution exists, your program should display the solved grid, with the columns aligned and the correct numbers in place of the blanks. For example:
If there is no solution, your program should display a message to that effect.
FOR EXTRA CREDIT: Implement an additional feature that checks to make sure that the puzzle solution is unique. This will involve continuing the search after the first solution is found (i.e., pretending that solution doesn't exist) to see if another solution can be found. If so, your program should warn the user that the puzzle has multiple solutions.