74 views

Uploaded by IJAFRC

Sudoku puzzles are logic-based number-placement puzzles and each has a unique solution. These
Sudoku puzzles are entertaining and are good exercise of the brain. There are number of
algorithms available to solve such Sudoku. In this paper we are comparing two different
algorithms Backtracking and Constraint propagation and also we have proposed a new method
improved version of constraint propagation. The improved constraint propagation solves the
Sudoku more efficientl and has less time and number of iterations.

- The Optimal Implementation of Functional Programming Languages_Cambridge Tracts in Theoretical Computer Science_Andrea Asperti and Stefano Guerrini_9780521621120 38538
- 18-JohanGroenen - Nurikabe
- Sudoku
- Include Back
- Analysis of algarorithms, day 2
- 14C13824-001_1_Ex1
- Board Games using Graph Theory
- Python Advanced_ Turing Machine in Python
- 22-Minimization.pdf
- runge kutta.pptx
- 6. Management-Mining Students Data to Predict Student
- New Microsoft Office Word Document
- Notes on Stacks
- Desarrollo Del Pensamiento Modulo 9
- Master Slave
- PR Minggu Ini
- L23_2_f07
- First Periodic Test Math XI
- hw4sol
- 1st PUC Computer Science Feb 2018

You are on page 1of 5

Anuj Thaker, Chinmay Sawant, Nikhil Patel,Prof. Avani Sakhapara

Dept. of Information Technology, K.J.Somaiya College of Engineering

anujthaker@somaiya.edu, chinmay.s@somaiya.edu, nikhil.patel@somaiya.edu,

avanisakhapara@somaiya.edu

Dept. of Information Technology, K.J.Somaiya College of Engineering, Mumbai

ABSTRACT

Sudoku puzzles are logic-based number-placement puzzles and each has a unique solution. These

Sudoku puzzles are entertaining and are good exercise of the brain. There are number of

algorithms available to solve such Sudoku. In this paper we are comparing two different

algorithms Backtracking and Constraint propagation and also we have proposed a new method

improved version of constraint propagation. The improved constraint propagation solves the

Sudoku more efficientl and has less time and number of iterations.

General Terms: Cell, Grid, Domain.

Keywords: Sudoku, Puzzle, Backtracking, Constraint Propagation, Improved Constraint

Propagation.

I.

INTRODUCTION

In real life we come across Sudoku puzzles of varying difficulty levels in newspapers and other text and

digital media. It is a common leisure activity for a lot of people. However, it is observed that the solution

is not always immediately available for the users verication. In most cases, people have to wait till the

next day to check the solutions of the Sudoku they just solved. Hence our motivation for this project was

to develop an application for it. In this method the user has to enter the values from the given Sudoku

problem and the algorithm returns the complete solution of the same. Sudoku is a logic based puzzle with

the goal to complete a 9x9 grid so that every row, every column and all of the nine 3x3 boxes contain the

numbers 1 through 9, given a partial filing to a unique solution. The problem itself is a popular

brainteaser but can easily be used as an algorithmic problem. The latest version of Sudoku was first

introduced in Japan in the eighties and has since then attracted a lot of programmers and therefore there

are a great deal of different Sudoku solving algorithms available on the Internet, both implementations

and construction methods. Sudoku solvers are interesting because they are practical applications of

theoretical problems, and most people are familiar with it.

Different algorithms have been used to solve this logical problem. We are using two different approaches

to solve the puzzle and will compare them. We will implement the Recursive Backtracking and Constraint

Propagation algorithms. Our task is to find the efficient algorithm between the two. The rest of the paper

is Section 2 the review of Literature, Section 3 Algorithms, Section 4 Result, Section 5 Conclusion and

Section 6 the References.

II. LITERATURE REVIEW

A. OVERVIEW

Approach used here is that the users are required to manually enter the Sudoku puzzle [1] and this

numbers are used in Backtracking algorithm [1] to generate the solution. The algorithm will randomly

1 | 2015, IJAFRC All Rights Reserved

www.ijafrc.org

Volume 2, Issue 5, May - 2015. ISSN 2348 4853

enter a number from 1 to 9 in the blank grid location and in case of some conflict in the Sudoku rules, we

will go back and change the number that we inserted before. Another method used here is Constrain

Propagation, where we check for possible entries for a blank location using a possibility array[2].

B. Algorithms

1. Backtracking algorithm

Here, for solving the Sudoku we use recursive backtracking tactics. After obtaining the empty virtual grid

and storing all the numbers from the image, we put zeroes for all the blank spaces we need to fill. To

obtain solution we identify all those spaces where there are zeroes and fill those spaces with numbers

from 1-9 based on Sudoku rules. We use this technique to find assignments at all the blank grid locations

recursively. Here what the algorithm does is assign a number to a blank location from 1-9 based on the

Sudoku rules and go to the next blank location, if there is some conflict in assigning value to a particular

blank space then the algorithm will go back to the previous location where we inserted the value, change

the assignment keeping the rules satisfied. When all the blank grid locations are filled we will display the

solved Sudoku to the user, if we fail to find solution for different blank grid locations we will use different

combination of numbers and try to solve the Sudoku. If all the combinations fail to give a solution, we

conclude that the particular grid is unsolvable.

2. Pseudo code

Procedure SUDOKUSOLUTION (row,col)

Begin

if row > 8

return true

if grid [row,col] is set

return NEXT(row,col)

else if grid[row,col] is zero

for i=1 to 9

if it does not violate constraints then

grid[row,col]=i

if NEXT(row,col)==true

return true

grid[row,col]=0

return false

End

Procedure NEXT(row,col)

Begin

if col==8

return SUDOKUSOLUTION(row+1,0)

else

return SUDOKUSOLUTION(row, col+1)

2 | 2015, IJAFRC All Rights Reserved

www.ijafrc.org

Volume 2, Issue 5, May - 2015. ISSN 2348 4853

End

C. Constraint Propagation

Constraint propagation is an algorithm that solves Sudoku problems by using possibility array and

multiple iterations. For this algorithm we will initially fill all the space with the values given in the

question, after that we will put zeroes in the blank locations. In this we will find all the possible numbers

for a particular blank location and we will have an array for each blank location, if for a particular blank

location there is only one possibility then we will directly insert the value in that location, otherwise we

will have multiple iterations following to complete the Sudoku problem. In some cases where the Sudoku

problem is of hard or extreme level we won't have a possible value after multiple iterations. For most of

the cases constraint propagation will be enough to fill the grid completely and without any conflict.

Limitations:

When single possible value is not available for some grids then the constraint propagation algorithm

enters infinite loop and consequently is unable to solve the Sudoku problem.

Modified Constraint Propagation:

The modified version that we are developing will be able to solve such Sudoku problems efficiently.

1. Pseudo code

Procedure init (grid[][])

Begin

for i=0 to 8 for j= 0 to 8

Cell[i][j] =grid[i][j]

Cell[i][j].domain.clear()

for i=0 to 8

for j= 0 to 8

if grid [i][j] is NOT 0

for k= 0 to 8

Cell[i][k].domain.remove(grid[i][j])

assignIfOnlyOne(i,k)

for k= 0 to 8

Cell[k][j].domain.remove(grid[i][j])

assignIfOnlyOne(k,j)

for k = 0 to 3

for kk = 0 to 3

Cell[floor(i/3)*3+k ][ floor(j/3)*3+kk]

.d

omain.remove(grid[i][j])

assignIfOnlyOne(k, kk)

End

Procedure assignIfOnlyOne (row, col)

Begin

3 | 2015, IJAFRC All Rights Reserved

www.ijafrc.org

Volume 2, Issue 5, May - 2015. ISSN 2348 4853

if(Cell[row][col].domain.size() ==1

Cell[row][col] = Cell[row][col].domain.get(0)

Cell[row][col].domain.clear()

for k= 0 to 8

Cell[i][k].domain.remove(values[i][j])

assignIfOnlyOne(i,k)

for k= 0 to 8

Cell[k][j].domain.remove(values[i][j])

assignIfOnlyOne(k,j)

for k = 0 to 3

for kk = 0 to 3

Cell[floor(i/3)*3+k ][ floor(j/3)*3+kk]

.domain.remove(values[i][j])

assignIfOnlyOne(k, kk)

End

III. RESULT

Comparing the time and number of iterations of Backtracking and Constraint Propagation.

Name of the

Time and Iterations

Time and Iterations

Time and Iterations

Algorithm

for Easy level sudoku

for Medium level

for Hard level

sudoku

sudoku

Backtracking

327 iterations

1501 iterations

12058 iterations

65 milliseconds

187 milliseconds

1040 milliseconds

Constraint

Propagation

1630 iterations

272 milliseconds

7386 iterations

580 milliseconds

60464 iterations

6052 milliseconds

Improved Constraint

Propagation

455 iterations

77 milliseconds

2823 iterations

250 milliseconds

23083 iterations

631 milliseconds

IV. CONCLUSION

The simulation result shows us that Backtracking algorithm give better solution for the 9x9 grid Sudoku

puzzle with no violation of constraints and it requires less time, number of iterations and has better

performance. On the other hand Constraint Propagation algorithm is more time consuming. We have

found certain limitations while executing constraint propagation i.e. When single possible value is not

available for some grids then the constraint propagation algorithm enters infinite loop and consequently

is unable to solve the Sudoku problem, so we have developed an improved version of constraint

propagation that solves the Sudoku problem more effectively.

V. ACKNOWLEDGMENT

We would like to thank K.J. Somaiya College of Engineering for the platform that they have provided us

and knowledge base, and most importantly we would like to acknowledge the help and efforts of Prof.

AvaniSakhapara.

4 | 2015, IJAFRC All Rights Reserved

www.ijafrc.org

Volume 2, Issue 5, May - 2015. ISSN 2348 4853

VI. REFERENCE

[1]

Arnab Kumar Maji and Rajat Kumar Pal, Sudoku Solving using Minigrid based Backtracking,

University

of

Kolkata

and

north

eastern

hill

university,

INDIA,

2014

[2]

Arnab Kumar Maji and Rajat Kumar Pal, Sudoku Solving using Minigrid based Backtracking,

University of Kolkata and north eastern hill university, INDIA, 2014

[3]

Ali Fatih Gunduz, Larasmoyo Nugroho, Afar Saranli," Sudoku Problem Solving using

Backtracking, Constraint Propagation, Stochastic Hill Climbing and Artificial Bee Colony

Algorithms",

[4]

http://en.wikipedia.org/wiki/Backtracking(accessed on 12/10/2014)

[5]

14}

www.ijafrc.org

- The Optimal Implementation of Functional Programming Languages_Cambridge Tracts in Theoretical Computer Science_Andrea Asperti and Stefano Guerrini_9780521621120 38538Uploaded byhexram
- 18-JohanGroenen - NurikabeUploaded byChristian Leonardo Puelles Caceres
- SudokuUploaded byZeire
- Include BackUploaded byPopa Monica
- Analysis of algarorithms, day 2Uploaded byAnil Reddy Manukonda
- 14C13824-001_1_Ex1Uploaded byCrowell Law
- Board Games using Graph TheoryUploaded byAbhinav Prasad
- Python Advanced_ Turing Machine in PythonUploaded byPedro Elias Romero Nieto
- 22-Minimization.pdfUploaded byKANTARIYA RISHIT
- 6. Management-Mining Students Data to Predict StudentUploaded byBESTJournals
- New Microsoft Office Word DocumentUploaded bySoumya Ranjan
- Desarrollo Del Pensamiento Modulo 9Uploaded byLuis Torres
- runge kutta.pptxUploaded byMohammad Rameez
- Notes on StacksUploaded byFoysal
- Master SlaveUploaded byrocket_spirit_mani
- PR Minggu IniUploaded byGloriaDorothy
- L23_2_f07Uploaded byam1li
- First Periodic Test Math XIUploaded byMarvin Darius Lagasca
- hw4solUploaded bylinchi
- 1st PUC Computer Science Feb 2018Uploaded byRaghu Gowda
- SCET_2nd_ass.Uploaded bytjthegreat
- Lecture 3 Complexity Analysis ReccuranceUploaded byMahimul Islam Akash
- SOLUTION_05_Poor.pdfUploaded bylaxmanababu
- 03.pdfUploaded byKeerthana Muniappan
- Lecture 2Uploaded byedwindove
- 03 Systems of Non Linear EquationsUploaded byİsmail Eren
- ChapterUploaded byVijay Kumar
- presentation1-101004122851-phpapp02Uploaded byShaik Afroz
- 02 Linear an Quadratic 0001Uploaded byArantxa Quiñones
- Lecture 20 - Euclidean Minimum-Weight MatchingUploaded bygdenunzio

- Effects Of Social Media On The Psychology Of PeopleUploaded byIJAFRC
- Detecting User Relevant ApplicationsUploaded byIJAFRC
- Performance Analysis and Lifetime Maximization of Wireless Sensor Network using Efficient Clustering AlgorithmUploaded byIJAFRC
- Data Security and Anonymization for Collaborative Data PublishingUploaded byIJAFRC
- Face Verification with Age Progression using Discriminative Method and Gradient Orientation PyramidUploaded byIJAFRC
- A Review Of BFOA Application To WSNUploaded byIJAFRC
- CFS based Feature Subset Selection for Software Maintainance PredictionUploaded byIJAFRC
- Detection and Defense of DDoS AttacksUploaded byIJAFRC
- A Review of Compact Asymmetric Coplanar Strip Fed Monopole Antenna for Multiband ApplicationsUploaded byIJAFRC
- Face Granulation using Difference of Gaussian (DOG) Method for Face RecognitionUploaded byIJAFRC
- Pocket Barcode Application-Data Transmission Between PDA & PC Using Wireless NetworkUploaded byIJAFRC
- DDos System: A Disparagement System with Cache Based and Question Generation in Client-Server ApplicationUploaded byIJAFRC
- The Various Ways of Programming and Embedding Firmware into an ARM Cortex-M3 Microcontroller Based HardwareUploaded byIJAFRC
- A Comparative Study Of K-Means, K-Medoid And Enhanced K-Medoid AlgorithmsUploaded byIJAFRC
- Monitoring Applications in Wireless Sensor NetworksUploaded byIJAFRC
- To Design And Algorithm Using Zero Watermarking With Stegnography For Text DocumentUploaded byIJAFRC
- Finding Efficient Initial Clusters Centers for K-MeansUploaded byIJAFRC
- A Study On Denial-Of-Service Attacks And Their Countermeasure ApproachesUploaded byIJAFRC
- A Survey On Designing Of Turbo Encoder & Turbo DecoderUploaded byIJAFRC
- Automated Leukemia Detection By Using Contour Signature MethodUploaded byIJAFRC
- Predictive Model for Blood-Brain BarrierUploaded byIJAFRC
- Metamaterial Based Fractal Body Worn Antenna –A ReviewUploaded byIJAFRC
- A Short Study On Effective Predictors Of Academic Performance Based On Course EvaluationUploaded byIJAFRC
- Perceptions on Data Aggregation in Wireless Sensor NetworkUploaded byIJAFRC
- Application of Malicious URL Detection In Data MiningUploaded byIJAFRC
- A Comparative study on Classification and Clustering Techniques Using Assorted Data Mining ToolsUploaded byIJAFRC
- Analytical Evolution of WIMAX Coded OFDM in Various Fading EnvironmentUploaded byIJAFRC
- Energy Efficient Reconfigurable Fixed Width Baugh-Wooley MultiplierUploaded byIJAFRC
- Designing Of Efficient FPGA Based Random Number Generators Using VHDL.Uploaded byIJAFRC

- DSPManualUploaded byAbdul Bais
- Fur Bath Height TechieUploaded bymangatamrit
- PI and PID controller tuning rules an overview and personal perspective.pdfUploaded byjalilemadi
- ARDLUploaded byMohammed Seid
- ClockingUploaded bykryptonites1234
- Optimization QuestionsUploaded byaditvas
- OverviewUploaded bysignalpardis
- aima-ch4.pdfUploaded by-Habibie Al Fatih Muhammad-
- Geocomp ProgrammeUploaded byspsoofbaf
- Cy Pro GraphyUploaded byMartin Skoda
- Hybrid Flow Shop Scheduling With Sequence Dependent Family Setup Time and Uncertain Due DatesUploaded bydaimon_p
- Tall AUploaded bykadalmon
- ClusterUploaded bypurple0123
- Blei Review VariationalInferenceUploaded byRacool Rafool
- Finite Precision EffectsUploaded byrcherr
- Dimensionality Reduction Report-Yomna Eid Rizk (3)Uploaded byYomna Eid
- 2.5 Modeling Real-world DataUploaded byKushagra Tiwary
- AC+2000Paper412Uploaded byEdu Daryl Maceren
- Private Computations Over The IntegersUploaded byΟλυμπίδης Ιωάννης
- Hadamard TransformUploaded byLucas Gallindo
- Constrained Particle Swarm Optimization of Mechanical SystemsUploaded byKennedy Ronoh
- 10.1.1.93Uploaded byalchemist_bg
- acsl 16-17 contest 4 notes - graph theory de assemblyUploaded byapi-328824013
- Solver Frontline Solvers Reference GuideUploaded byCDH2346
- 12-Binary Search TreesUploaded byFatima Mattar
- Chaos BookUploaded byH
- Thesis 2Uploaded byMadasamy Rathinam R
- Golub FlyerUploaded bySaher
- AppendixUploaded bypuyang48
- FFT.pptUploaded byvivek singh