A Sudoku puzzle commonly consists of a 9x9 matrix, and the objective is to fill the matrix with the digits 1 through 9 such that each digit appears exactly once in each row, column, and 3x3 sub-block.

Problem Task

The task for this part of the assignment is to write a Python application called sudokuchecker.py that will read in a partially-solved Sudoku puzzle from a text file and check to see if it contains valid digits. If the same number occurs twice in a row, column, or block, the puzzle is invalid. The text file will only contain the puzzle, with blanks represented by zeroes, and no other lines or data. Ask the user to enter the filename of the input file, and then output whether or not the puzzle is valid. You may assume that the input file given will contain a puzzle.

Two sample input files (q1-1.in and q1-2.in) are provided, however you should test your program on additional puzzles to ensure you have covered all cases.

Sample Run

[evaluate sudokuchecker.py]
Enter the input filename: q1-1.in
The puzzle is valid!
[evaluate sudokuchecker.py]
Enter the input filename: q1-2.in
The puzzle is not valid!
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.