600.108 Intro Programming Lab Week 8 PROBLEM STATEMENT: Write a program to be a Sudoku solution checker! More specifically, the program must read a file containing numbers in a 9x9 grid (9 integers per row, 9 rows), and then check to see if the numbers are a valid solution to a sudoku puzzle. A valid solution contains each of the numbers 1 through 9 in every row, column and 3x3 sub-grid. Get user input for the filename, and display the valid or invalid result on the screen. If the grid is invalid, give at least one reason why (row number, column number or cube number). (In the posted examples, we give all reasons.) When displaying invalid rows, columns or cubes, refer to them with the numbers 1-9 (not 0-8) because that will make more sense to the user. Assume the numbers in the input file are separated by spaces. You can find a bunch of puzzles on various websites. A nice one that includes solutions (which you can use to test your program) is www.dailysudoku.com We have posted two sample input files: sudoku1.txt and sudoku2.txt. In addition to the input, the results of checking each grid are in each file as well. (Just ignore those lines when reading the files.) PHASE 1: Problem Analysis & Design - Think about how you will need to solve this problem. Basically, you have to do the same kind of checking for each row, column and sub-cube. You should do an object oriented solution which creates a Sudoku class to hold and manipulate a puzzle, and a main program to control things. Think about the data and methods needed for the Sudoku class. Read through all the phases below for some ideas on how to break things down. Sketch the structure of this class by writing headers for all the methods you will use, include dummy values where needed to make it compile. PHASE 2: Create a main program which should handle the input processing details. Make it so that it will get the name of an input file from the user, create a puzzle object, read from the file to initialize the puzzle, and then display the puzzle on the screen. The last two operations should call methods in your Sudoku class to do the work. Write the bodies of these methods. Compile, run and test. PHASE 3: In your Sudoku class, create a method which has a one dimensional array of 9 integers as a parameter and checks whether it contains each value 1 through 9 exactly once. This method can be static. Now write an instance method to check all rows by calling this method on each row in the puzzle, displaying the numbers of any invalid ones. Call the instance method which checks all rows from main on your puzzle object. PHASE 4: Now figure out how to use the static array check method to deal with a column instead. Once you have that worked out, add an instance method in Sudoku to use it on every column. Call this instance method from main on your puzzle object. (Hint: copy each column into a 1 dimensional array.) PHASE 5: Lastly, figure out how to similarly process each subcube. If you have time, combine the calls to check the rows, columns and subcubes into one validate method in the Sudoku class. Replace the three separate method calls in main with one validate call. ************************************************** MAKE SURE YOU DELETE YOUR FILES OFF THE LAB COMPUTER WHEN DONE!!! FAILURE TO DO SO IS AN ETHICS VIOLATION! **************************************************