Question: C++ I add the 4 puzzle files for testing below and each can be saved as format text (word pad): 0 3 0 8 0
C++


I add the 4 puzzle files for testing below and each can be saved as format text (word pad):
0 3 0 8 0 0 5 0 0 0 0 0 5 0 0 7 1 0 0 0 0 2 7 0 0 6 0 0 0 6 0 8 0 0 0 4 0 0 0 0 0 6 0 0 0 0 4 0 7 0 0 3 5 0 0 7 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 9 0 3 4 0 0 7
0 0 3 4 0 6 0 0 0 9 0 0 0 0 0 0 0 0 0 7 0 0 0 0 1 0 3 0 0 9 1 0 2 0 0 0 0 0 0 0 0 0 5 0 4 0 0 0 0 0 0 2 8 0 0 1 2 0 0 0 0 7 0 4 0 0 3 1 0 0 2 0 6 0 0 0 9 0 0 3 0
7 0 3 4 0 6 8 0 0 8 0 0 7 0 5 4 6 9 4 5 6 8 9 0 0 0 0 0 8 0 0 5 9 0 1 0 3 0 2 0 0 8 0 0 6 0 1 0 0 0 0 3 8 7 0 0 0 0 4 0 6 0 0 0 0 0 5 1 0 9 3 0 0 7 5 0 8 0 0 0 2
0 0 3 4 0 6 0 0 0 9 0 0 0 0 0 0 0 0 0 7 0 0 0 0 1 0 3 0 0 9 1 0 2 0 0 0 0 0 0 0 0 0 5 0 4 0 0 0 0 0 0 2 8 0 0 1 2 0 0 0 0 7 0 4 0 0 3 1 0 0 2 0 6 0 0 0 9 0 0 3 0
1. Overview We are going to write C++ program to solve Sudoku puzzle. Sudoku is a puzzle where you ri numbers into a grid. The Sudoku rules are: fill the empty squares in the 9 x 9 grid so that each square contains a number in the range (1... 9) in each row and each column across the grid, the numbers (1 9) appear just once (Sudoku means "single"). Likewise, each of the nine 3 x 3 squares that make up the grid must contain the just numbers 1. S. 2. Sudoku Strategy There are many ways to solve Sudoku. We will be using the classic recursive backtracking search. We will call each square in the puzzle a "Spot". We want to do recursive backtracking search for a solution, assigning numbers to spots to find a combination that works. When assign a number to a spot, never assign a number that conflicts with the spot's row, column and square. Assume that the initial grid is legal, and make only legal spot assignment thereafter. There are 81 spots in the puzzle. You could try making assignments to the empty spots in any order. However, for our solution, first sort the spot into order by the size of their set of assignable numbers, with the smallest set (most constrained) spot first. Follow that order in the recursive search. 3. Sudoku OOP design We map out the classes together with their data members and member functions in the following class diagram. 1. Overview We are going to write C++ program to solve Sudoku puzzle. Sudoku is a puzzle where you ri numbers into a grid. The Sudoku rules are: fill the empty squares in the 9 x 9 grid so that each square contains a number in the range (1... 9) in each row and each column across the grid, the numbers (1 9) appear just once (Sudoku means "single"). Likewise, each of the nine 3 x 3 squares that make up the grid must contain the just numbers 1. S. 2. Sudoku Strategy There are many ways to solve Sudoku. We will be using the classic recursive backtracking search. We will call each square in the puzzle a "Spot". We want to do recursive backtracking search for a solution, assigning numbers to spots to find a combination that works. When assign a number to a spot, never assign a number that conflicts with the spot's row, column and square. Assume that the initial grid is legal, and make only legal spot assignment thereafter. There are 81 spots in the puzzle. You could try making assignments to the empty spots in any order. However, for our solution, first sort the spot into order by the size of their set of assignable numbers, with the smallest set (most constrained) spot first. Follow that order in the recursive search. 3. Sudoku OOP design We map out the classes together with their data members and member functions in the following class diagram
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
