Project Report For Sudoku Solver
Project Report For Sudoku Solver
Project Report For Sudoku Solver
Sudoku Solver
[For teachers use only: Don’t write anything inside this box]
Marks: Signature:
Comments: Date:
Contents
1 Introduction 3
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Problem Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Complex Engineering Problem . . . . . . . . . . . . . . . . . . 4
1.4 Design Goals/Objectives . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5.1 Output visualization . . . . . . . . . . . . . . . . . . . . . . . 6
3 Performance Evaluation 17
3.1 Simulation Environment/ Simulation Procedure . . . . . . . . . . . . . 17
3.2 Results Analysis/Testing . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.1 Result_Case_1 . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.2 Result_Case_2 . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1
3.2.3 Result_Case_3 . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3 Results Overall Discussion . . . . . . . . . . . . . . . . . . . . . . . . 21
3.3.1 Complex Engineering Problem Discussion . . . . . . . . . . . 21
4 Conclusion 23
4.1 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Scope of Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2
Chapter 1
Introduction
1.1 Overview
The Sudoku solver game is a puzzle where players fill a 9x9 grid with numbers from 1 to
9, ensuring each row, column, and 3x3 sub grid contains all numbers without repetition.
Players input numbers, validate their choices, and a solver algorithm finds the solution
using backtracking. Hints may be provided, and players can request assistance. Once
the grid is filled, the game displays the solution. Sudoku offers a challenging experience
that requires logical thinking and problem-solving skills.
1.2 Motivation
The Sudoku solver game offers an engaging and enjoyable experience for players of all
skill levels. It serves as a valuable tool to improve problem-solving abilities, learn Su-
doku strategies, and develop logical reasoning skills. By observing the solver algorithm,
players can enhance their problem-solving techniques and gain a sense of accomplish-
ment. The game provides a platform to practice, learn, and experience the satisfaction
of solving challenging Sudoku puzzles. Embrace the challenge, sharpen your mind, and
enjoy the journey of Sudoku solving with the Sudoku solver game. [?].
• Input: The program should accept a 9x9 grid as input, representing a partially
filled Sudoku puzzle. The input grid should contain numbers from 1 to 9, with 0
or empty cells denoting the blank spaces.
• Validation: The program should validate the input grid to ensure it follows the
rules of Sudoku. Each row, column, and 3x3 subgrid should contain all numbers
3
from 1 to 9 without repetition. If the input grid violates the Sudoku rules, the
program should indicate an invalid input.
• Solution Output: Upon successful solving of the Sudoku puzzle, the program
should output the complete solution. The output should be a 9x9 grid where all
empty cells are filled with valid numbers, satisfying the Sudoku rules.
• Efficiency: The solver program should efficiently find the solution to Sudoku
puzzles of varying difficulty levels. It should minimize unnecessary computations
and provide a timely response for both simple and complex puzzles.
• User Interface (optional): To enhance the user experience, the program may in-
clude a user interface where users can input the Sudoku puzzle, view the solution,
and interact with the solver algorithm. The user interface can provide features
such as hints, error checking, and the ability to enter puzzles step by step.
The goal of the Sudoku solver program is to provide an automated solution for Sudoku
puzzles, enabling users to solve puzzles quickly and effortlessly. The program should
deliver accurate and efficient results while maintaining the integrity of the Sudoku rules.
1.5 Application
The Sudoku-solving game has various applications that cater to puzzle enthusiasts, edu-
cational institutions, and anyone looking to improve their problem-solving skills. Here
are some key applications of the Sudoku-solving game:
4
• Entertainment and Recreation: The Sudoku-solving game provides a fun and en-
gaging activity for individuals of all ages. It offers a challenging puzzle-solving
experience that can be enjoyed during leisure time or as a mental exercise to un-
wind and relax.
• Skill Development: The Sudoku solving game serves as a valuable tool for devel-
oping and honing problem-solving skills. It enhances logical reasoning, critical
thinking, pattern recognition, and strategic planning abilities. Regularly engaging
in Sudoku solving can lead to improved cognitive skills and mental agility.
• Educational Tool: The Sudoku solving game finds application in educational set-
tings, such as schools and educational institutions. It can be used to introduce and
teach concepts like logic, deductive reasoning, and number patterns. It encour-
ages students to think analytically and boosts their problem-solving capabilities.
• Personal Growth: The Sudoku solving game promotes personal growth by fos-
tering perseverance, patience, and the ability to handle challenges. It encourages
individuals to overcome obstacles, learn from mistakes, and strive for continuous
improvement. The game cultivates a growth mindset and a sense of accomplish-
ment upon successfully solving puzzles.
• Brain Training: The Sudoku solving game is often used as a brain-training exer-
cise to keep the mind sharp and active. Regular practice helps maintain mental
acuity and memory retention. It offers a stimulating workout for the brain and
can be part of a comprehensive brain-training regimen.
In summary, the Sudoku solving game has versatile applications, ranging from enter-
tainment and skill development to educational use and personal growth. It offers an en-
joyable and beneficial experience that challenges the mind, promotes problem-solving
skills, and enhances cognitive abilities.
5
1.5.1 Output visualization
6
Table 1.1: Summary of the attributes touched by the mentioned projects
Name of the P Attributes Explain how to address
P1: Depth of knowledge required Familiarity with logical reasoning, number pat-
terns, and problem-solving techniques is essen-
tial to effectively solve Sudoku puzzles.
P2: Range of conflicting require- Balancing efficiency and accuracy, while pro-
ments viding user-friendly features and maintaining
adherence to Sudoku rules, presents a range of
conflicting requirements in Sudoku solving.
P3: Depth of analysis required The depth of analysis required for Sudoku solv-
ing involves employing advanced logical de-
duction techniques, including complex patterns
and inter-dependencies, to uncover hidden rela-
tionships and make precise choices.
P4: Familiarity with issues Developing familiarity with common issues in
Sudoku solving, such as invalid input, unsolv-
able puzzles, and efficient algorithms, helps en-
sure accurate solutions and a smooth solving
experience
P5: Extent of applicable codes The applicable codes for Sudoku solving en-
compass algorithms for puzzle generation, val-
idation, backtracking, and user interface imple-
mentation.
P6: Extent of stakeholder involve- Balancing the input and expectations of di-
ment and conflicting requirements verse stakeholders while managing conflicting
requirements to create a Sudoku solving solu-
tion that satisfies various user preferences and
objectives.
P7: Interdependence The successful solving of Sudoku puzzles re-
lies on the interdependence between logical de-
duction, pattern recognition, and the ability to
eliminate possibilities through iterative testing
and backtracking.
7
Chapter 2
Design/Development/Implementation
of the Project
2.1 Introduction
The Sudoku Solving project is a user-friendly application centred around a 9x9 grid
panel and three key buttons: "Sudoku Generate," "Solve," and "Clear." It provides an
intuitive interface for generating, solving, and clearing Sudoku puzzles. The "Sudoku
Generate" button creates valid and solvable puzzles, displaying them on the grid panel.
The "Solve" button employs efficient algorithms to determine the solution, updating the
grid dynamically. The "Clear" button resets the grid for new challenges. The project
prioritizes user experience and interface design, offering a sleek platform for Sudoku
enthusiasts.
8
• Clear Functionality: The "Clear" button resets the Sudoku grid to its initial state,
allowing the user to start a new puzzle or erase their progress on the current one.
results in a clear and intuitive manner.
9
2.3 Implementation
The project employs a graphical user interface (GUI) that includes a 9x9 grid panel
representing the Sudoku puzzle. Each cell in the grid can be populated with a digit
from 1 to 9, or left empty for the user to fill. The interface is intuitive and user-friendly,
with clearly labeled buttons and visual cues to guide the user’s interactions.
• Empty Grid Initialization: The algorithm begins with an empty 9x9 Sudoku
grid where all cells are initialized to be empty.
10
2.3.3 Sudoku Solving Algorithm:
The Sudoku-solving algorithm is responsible for finding the solution to a given Sudoku
puzzle. It employs an efficient approach that systematically explores possible digit
placements in empty cells while ensuring that all Sudoku rules are satisfied. Here are
more details about the Sudoku-solving algorithm:
• Empty Cell Selection The algorithm starts by selecting an empty cell in the Su-
doku grid to fill. It can follow various strategies for selecting the next cell, such
as choosing the top-leftmost empty cell or selecting the cell with the fewest pos-
sibilities.
• Digit Placement: For the selected empty cell, the algorithm attempts to place a
digit (1 to 9) that satisfies the Sudoku constraints. It checks if the chosen digit
violates any rules within the cell’s row, column, or 3x3 sub-grid. If a conflict
arises, the algorithm backtracks and tries a different digit.
• Recursive Exploration: After placing a digit in the current cell, the algorithm
recursively explores the next empty cell, repeating the digit placement process.
This recursive exploration continues until all cells are filled, and a valid solution
is found. If a conflict occurs in any step, the algorithm backtracks to the previous
cell and tries a different digit until a solution is ultimately found.
• olution Verification: Once a solution is obtained, the algorithm verifies its cor-
rectness by ensuring that it satisfies all Sudoku constraints. It checks that no digit
is repeated in any row, column, or 3x3 sub-grid. If the solution is invalid, the
algorithm continues the backtracking process to find an alternative solution or
reports that the puzzle is unsolvable.
11
2.3.4 Visualization Techniques:
The project incorporates a time delay feature to showcase the solving process gradually.
By introducing a pause between each step, the user can observe how the algorithm
progresses through the puzzle. The time delay can be adjusted based on the desired
speed of the animation, allowing the user to follow the solving process at their own
pace.
The Sudoku Solving project offers a user-friendly interface for generating and solving
Sudoku puzzles. Upon launching the application, a 9x9 grid panel is displayed, repre-
senting the Sudoku puzzle. The user can click the "Sudoku Generate" button to create a
new puzzle, which is populated with a unique solution. Manual input is optional, allow-
ing the user to enter digits into empty cells. By clicking the "Solve" button, the solving
algorithm starts and gradually fills the cells using a backtracking approach. Time delay
visualization and color highlighting enhance the user experience, showcasing the solv-
ing process step by step. Once a solution is found, the completed puzzle is displayed
on the grid. The "Clear" button allows the user to reset the grid. The project provides
an intuitive interface for users to interact with Sudoku puzzles, making it enjoyable and
engaging.
12
Figure 2.2: User Interface / Buttons Of Visualizer
2.4 Algorithms
Algorithm is the prepossess to solve a problem.It is noting but a step by step procedure
for the full program.Here is the main algorithm part for my project .
13
Algorithm 1: Sudoku Solving Algorithm
Input: Sudoku grid
Output: Boolean indicating if Sudoku is solved
/* Backtracking */
/* If the solution is wrong, reassign the value */
10 get [row][col] = 0
11 return false;
12 public boolean solveSudoku() ();
14
Algorithm 2: Find Empty Location in Sudoku Grid Algorithm
Input: Sudoku grid, row, col
Output: Array with flag, row, and column values
1 public int[] FindEmptyLocation((int row, int col))
2 int flag = 0; // Iterate through each cell in the Sudoku grid for (int i = 0; i <
SIZE; i++) for (int j = 0; j < SIZE; j++) // Check if the cell is empty if (get
[i][j] == 0) // Assign the row and column values of the empty cell row = i; col
= j; flag = 1;
3 // Create an array with flag, row, and column values int[] a = flag, row, col;
return a;
4 // If no empty cell is found, return an array with flag = 0 and row = -1, col = -1
int[] a = flag, -1, -1; return a;
5 // Example usage of the FindEmptyLocation function int row = 0; int col = 0;
int[] result = FindEmptyLocation (row, col);
5 // Check if number n already exists in the same row for int i = 0; i < SIZE; i++
do
6 if get [i][c] == n then
7 return false
13 return true
14 // Example usage of the NumberIsSafe function int number = 5; int row = 2;
int col = 4; boolean isSafe = NumberIsSafe (number, row, col);
15
15
Algorithm 4: Sudoku Solving Algorithm
Input: Sudoku grid
Output: Boolean indicating if Sudoku is solved
1 solveSudoku()
// Recursive function to solve the Sudoku puzzle
// Find the first empty location in the Sudoku grid
// If no empty location is found, the Sudoku is already
solved
// Initialize row and column variables
2 row ← 0 col ← 0 []a ← FindEmptyLocation(row, col)
// If there are no empty locations, Sudoku is already solved
3 if a[0] == 0 then
4 return true
// Backtracking
// If the solution is wrong, reassign the value
11 get [row][col] ← 0
12 return false
13 solveSudoku ()
16
Chapter 3
Performance Evaluation
• Integrated Development Environment (IDE) such as Visual Studio code. this case,
I have used Visual Studio code editor
Device
• Brand: Dell
• Colour: Silver
• SSD: 512 GB
17
3.2 Results Analysis/Testing
The Sudoku Solving project aims to provide a user-friendly interface for generating
and solving Sudoku puzzles. It utilizes a 9x9 grid panel and incorporates three main
buttons: "Sudoku Generate," "Solve," and "Clear." The "Sudoku Generate" button gen-
erates a new Sudoku puzzle with a unique solution, offering users fresh challenges.
The "Solve" button triggers the solving algorithm, visually displaying the step-by-step
solving process on the grid. It employs time delay visualization to enhance the user
experience. The "Clear" button allows users to reset the grid, providing a clean slate for
new puzzles or starting over. Together, these buttons create an interactive environment
for users to generate, solve, and engage with Sudoku puzzles..
3.2.1 Result_Case_1
18
3.2.2 Result_Case_2
19
3.2.3 Result_Case_3
Clear Button:
This is the picture of clear Button work
20
3.3 Results Overall Discussion
The Sudoku Solving project offers a user-friendly interface for generating and solving
Sudoku puzzles. With a 9x9 grid panel and three main buttons, namely "Sudoku Gener-
ate," "Solve," and "Clear," the project provides a comprehensive experience for Sudoku
enthusiasts.
The "Sudoku Generate" button generates new puzzles, ensuring a unique solution
each time. The Sudoku generation algorithm populates a random selection of cells in
the grid, resulting in puzzles with varying levels of difficulty. This feature allows users
to have a continuous supply of fresh challenges.
The "Solve" button triggers the Sudoku solving algorithm, which employs a back-
tracking approach to fill the empty cells systematically. The solving process is visually
displayed on the grid, with a time delay feature and color highlighting for enhanced
visualization. Users can observe each step of the algorithm and gain insights into the
solving process.
The "Clear" button provides a convenient option for users to reset the grid to its
initial state. This feature allows users to start fresh with a new puzzle or erase their
progress on the current one, ensuring flexibility and convenience.
By combining these functionalities, the Sudoku Solving project offers an interactive
and engaging experience. Users can generate new puzzles, solve them with the assis-
tance of the algorithm, and reset the grid as needed. The project provides a user-friendly
interface, making it accessible to Sudoku enthusiasts of all skill levels.
21
hand, the solving algorithm must be efficient and capable of solving puzzles in
a reasonable amount of time. The user interface should be intuitive and visually
appealing while also providing clear feedback and visualizations of the solving
process. Balancing these conflicting requirements requires careful consideration,
such as finding the right balance between generating complex puzzles and en-
suring solvability, optimizing the solving algorithm for speed without sacrificing
accuracy, and designing a visually appealing and informative interface. Striking
the right balance is crucial to create a Sudoku Solving project that offers enjoy-
able and challenging puzzles while providing a seamless user experience.
4. Extent of Applicable Codes: The Sudoku Solving project involves the imple-
mentation of various codes. This includes code for puzzle generation to create
Sudoku puzzles of different difficulty levels, code for the solving algorithm to
find solutions using backtracking or other search algorithms, code for the user
interface to provide an interactive grid, buttons, and visual feedback, code for
validation and error handling to ensure the entered puzzles are valid and solvable,
code for time delay and visualization techniques to demonstrate the solving pro-
cess gradually, code for performance optimization to enhance efficiency, and code
for testing to validate the implemented functionalities. The extent of applicable
codes for the project spans puzzle generation, solving, user interface, validation,
time delay, visualization, performance optimization, and testing, all of which con-
tribute to the successful implementation and functionality of the Sudoku Solving
project.
22
Chapter 4
Conclusion
4.1 Discussion
The Sudoku Solving project utilizes a user-friendly interface with three buttons: "Su-
doku Generate," "Solve," and "Clear." The "Sudoku Generate" button generates a unique
Sudoku puzzle, while the "Solve" button applies an algorithm to solve the puzzle step-
by-step, visually displaying the progress. The "Clear" button resets the grid. Overall,
the project offers an enjoyable Sudoku-solving experience with puzzle generation, solv-
ing algorithm implementation, and user interaction.
4.2 Limitations
limitations include:
• Inability to Solve Invalid Puzzles: The solving algorithm assumes that the in-
put puzzle is a valid Sudoku configuration. If an invalid or unsolvable puzzle
is provided, the algorithm may run indefinitely or produce incorrect results. It
is important to ensure that the project includes appropriate error handling and
validation mechanisms to prevent such scenarios.
23
4.3 Scope of Future Work
Scope of Future Work for the Sudoku Solving Project:
• Puzzle Validation and Error Detection: Enhancing the project to include puzzle
validation and error detection mechanisms would help identify invalid or unsolv-
able puzzles at the input stage. This would prevent the solving algorithm from
running indefinitely on incorrect puzzles and provide users with immediate feed-
back on the validity of their inputs.
• Additional Grid Sizes and Variations: Extending the project to support dif-
ferent grid sizes and variations of Sudoku, such as 4x4, 16x16, or irregularly
shaped grids, would provide users with more puzzle options and challenges. Im-
plementing additional grid sizes would require modifying the solving algorithm
and adapting the user interface to accommodate the changes.
24
4.4 References
Please Visit the Following Link For More Information:
• https://youtu.be/tRj4VlVTat8
• https://youtu.be/qH9mWpYMtYU
25