INTRODUCTION: Sudoku is just a puzzle, but the backtrackingtechnique for solving it is used in many important application domains.To solve a Suduku without backtracking, you could generate everypossible solution, then evaluate all of them and collect the legal ones.But there are 9^81 ways to fill in a Sudoku grid. 9^81 is ~= 2*10^77. Ifyou could evaluate a billion grids per second, it would take 2*10^68seconds. The universe is less than 10^18 seconds old. For thishomework, you will learn the power of backtracking by writing aSudoku solver that finds answers in just a few seconds.The puzzle on page 1, and all puzzles that appear in the code, arecopyright 1997-2016 Conceptis Ltd.SUDOKU Rules: A puzzle looks like the one on the previous page: a 99grid with some numbers filled in. The challenge is to fill in each emptyspace with a digit 1 through 9, so that no digit is repeated in any row,column or block. Block is my name for the nine 33 blocks outlinedin thicker black lines in the picture.Your Assignment: In the Eclipse workspace of your choice, create anew Java project containing package sudoku. Import the 4 starter filesthat you downloaded with this assignment: Evaluation.java, Grid.java,Solver.java, and TestGridSupplier.java. You wont need to changeEvaluation.java or TestGridSupplier.java. Your assignment is to finishGrid.java and Solver.java.Grid: This class models a Sudoku puzzle that is unsolved, partiallysolved, or completely solved. The class has a 99 array of ints, calledvalues. If a Sudoku square is empty, the corresponding cell in valuesis zero; otherwise the cell in values contains the number in the Sudokusquare. The starter class has a ctor and a toString() method that youshould not change. It also has 4 empty methods that you need to write:next9Grids(), isLegal(), isFull(), and equals(). Do not change theirnames, arg lists, or return types. The comments on the unfinishedmethods tell you all you need to know about what they should do. Its okto add more methods to this class.You dont need to provide this class with hashCode() or compareTo()methods. The equals() method is just so that you can compare yourpuzzle solutions to solutions in TestGridSupplier. (That is, you wont becollecting Grid instances into a hash set a tree set.)Solver: Most of this class has already been written. Complete thesolveRecurse() method using the backtracking technique you saw inlecture and lab. Also complete the evaluate() method. The main()method is for you to use while testing your code with the puzzles andsolutions in TestGridSupplier.Evaluation: You saw this enum in lecture and lab. It contains 3 valuesthat represent the 3 possible outcomes of the evaluate() method of theGrid class. Look at the source code. Sometimes enums can becomplicated, but this one is not. You might need to write a very simpleenum for the next midterm.TestGridSupplier: This class contains static methods that return Gridinstances. Some of them are puzzles, some are solutions, and some arefor testing your code. Extra credit: are they useful? Comment on Piazzafor participation points.
Programming
[Solved] SOLVED: Homework5: Sudoku
$25
File Name: SOLVED:_Homework5:_Sudoku.zip
File Size: 235.5 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.