fulltext01.pdf

44
Comparison of how common sudoku solving techniques perform when adapted and applied to jigsaw sudokus WICKMAN TOMAS, ÖHMAN EMIL Bachelors Thesis Stockholm, Sweden 2014

Upload: le-thi-phuong-vien

Post on 18-Aug-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Comparison of how common sudoku solving techniquesperform when adapted and applied to jigsaw sudokusWICKMAN TOMAS, HMAN EMILBachelors ThesisStockholm, Sweden 2014KTH School of Computer Science and CommunicationSE-100 44 StockholmSWEDENiiiAbstractSudoku and Jigsaw sudoku are two similar logic puzzles. The goal of thepuzzles is to place numbers in a 9*9 grid until certain rules are met. In bothJigsaw sudoku and normal sudoku the numbers 1 to 9 needs to be placed inevery row, column and box. The dierence between the two puzzles is thatin a normal sudoku every box is a symmetric 3*3 square, while in the jigsawvariant the boxes have irregular, altough still nine cells big, boxes.When implementing algorithms for solving the normal sudoku, it normal tousethefactthatall theboxesaresymmetric. Thiswill notworkforthejigsaw sudoku though.In this report we will investigate the eectiveness of the three most commonsudoku solving algorithms Rule Based backtracking, Human-Like solving andDancing Links and how we arrived at the result that Human-Like solving was,in almost every case, the most eective algorithm for solving both sudoku andjigsaw sudoku.ivSammanfattningSudoku och Jigsaw sudoku r tv likartade logikspel som gr ut p attplacera ut tal enligt vissa regler p en spelplan som har 9*9 rutor. I Bdejigsawsudokuochvanligtsudokuskatalenetttill nionnasmedi varjekolumn, rad och box exakt en gng. Det som skiljer dem t r att i sudokur boxarna symmetriska och 3*3 rutor stora medan i jigsaw sudoku har devarierande form av 9 rutor.Vid implementation av algoritmer fr lsning av sudoku r det enkelt att an-vnda symmetrin av hur de ser ut, medan det fr jigsaw sudoku inte fungerard boxarna ej r symmetriska.I denna rapport undersker vi eektiviteterna hos de tre algoritmerna RuleBased backtracking, Human-Like solving och Dancing Link fr att visa hurvi kom fram till resultatet att Human-Like solving i nstan alla fall var deneektivare algoritmen bde fr vanliga sudoku och jigsaw sudoku.STATEMENT OF COLLABORATION vStatement of collaborationBoth have been working on large parts together but we still have divided our re-sponsibilities so that time consuming parts do not need to be done together:Implementions: Tomas has been responsible for the study of algorithm im-plementations that could be applied to jigsaw sudoku and regular sudoku.Implementationresearchof sudokuandjigsawsudokusandhowthetimemeasurement will be done has been Emils responsibility.Reportwriting: Emil hasbeenresponsiblefortheintroductionandback-ground. The methods rst part has Emil been responsible for and the secondparthasTomasbeenresponsiblefor. Tomashasbeenresponsibleof thewriting of Appendix A and Emil of the making of describing images.Remaining parts: The non mentioned parts has been both responsibilities.ContentsStatement of collaboration . . . . . . . . . . . . . . . . . . . . . . . . . . . vContents vi0.1 Denitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Introduction 31.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Problem description . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Background 52.1 What is a sudoku . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 What is a jigsaw sudoku? . . . . . . . . . . . . . . . . . . . . . . . . 62.3 How will the solving dier? . . . . . . . . . . . . . . . . . . . . . . . 63 Methods 93.1 Measuring time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Comparison setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.3 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Results 134.1 Hardware used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2 Average time of sudokus (s) . . . . . . . . . . . . . . . . . . . . . . 134.3 Average time of jigsaw sudoku (s) . . . . . . . . . . . . . . . . . . . 144.4 Comparison between jigsaw sudoku and normal sudoku . . . . . . . 154.5 Discussion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.6 Self-criticism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Appendix A 195.1 Rule Based Backtracking . . . . . . . . . . . . . . . . . . . . . . . . . 195.2 Human-Like Solving . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.3 Dancing Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Bibliography 37vi0.1. DEFINITIONS 10.1 DenitionsGridConsists of the entire puzzle, 9*9 cells.Nonominos9 neighbouring cells of the Jigsaw puzzle that contains the numbers 1-9 exactlyonce.Box3*3 cells of a Sudoku game that contains the numbers 1-9 exactly once.Cell1*1 section for a number of the puzzle that can contain only one of the numbers1-9.RowA row of 9 cells that contains the numbers 1-9 exactly once.ColumnA column of 9 cells that contains the numbers 1-9 exactly once.Chapter 1Introduction1.1 PurposeWhat makes this subject interesting is that sudoku is a well investigated and knownsubject, but not similar games that has many similarities. Therefore it is interestingto investigate how the most common sudoku solving algorithms performs on variousjigsaw sudokus and try to compare the results with similar diculties of normalsudokus. We will compare the results on terms of computation time. With theknowledge of how the algorithms compare comes a deeper understanding of whichalgorithms are the best under dierent circumstances.1.2 Problem descriptionThere are many dierent ways of solving a jigsaw sudoku puzzle both by comput-ers and by humans. This report will investigate the three algorithms Rule Basedbacktracking, Human-Like solving and Dancing Link.3Chapter 2Background2.1 What is a sudokuSudoku is a logic based puzzle with a 9*9 cell grid consisting of non-overlappingboxes of 3*3 cells. When starting to solve the puzzle, it consists of 17-30 cells withnumbers between 1-9 prelled. The more dicult the game is, the less prelledcells it will have[4]. The goal is to ll each cell of the puzzle with a number between1-9 according to the following rules.1. No box is allowed to have multiple cells with the same number.2. Each row of the grid contains all numbers between 1-9.3. Each column of the grid contains all numbers between 1-9.4. Only one number in each cell.Each puzzle has only one solution [4]. The puzzle got popular in Japan in themid of the 1980:s [4] and started to grow nationally in Sweden in the spring of year2005 [4][5].56 CHAPTER 2. BACKGROUNDFigure 2.1: A sudoku1.2.2 What is a jigsaw sudoku?Jigsaw sudoku is a logic based puzzle with a 9*9 grid consisting of non-overlappingirregular shapes of 9 cells with no empty holes in it called nonominoes. At startthe puzzle consists of various numbers of cells between 1-9 prelled depending ofthe diculty of the game. The goal is to ll each cell of the puzzle with a numberbetween 1-9 according to the following rules.1. No nonomino is allowed to has multiple cells with the same number.2. Each row of the grid contains every number between 1-9 exactly once.3. Each column of the grid contains every number between 1-9 exactly once.4. Only one number in each cell.Each puzzle has only one solution.2.3 How will the solving dier?In contrast to normal sudoku the jigsaw sudoku does not have symmetrical boxes.This allows for some new problems and some new possibilities when it comes tosolving the puzzles. When solving with Dancing Links for example we will haveto use dierent constraints in the matrix in order to solve the jigsaw sudokus incomparison to the normal sudokus.1http://commons.wikimedia.org/wiki/File:Sudoku-by-L2G-20050714.gif2.3. HOW WILL THE SOLVING DIFFER? 7Figure 2.2: A jigsaw sudoku2.The human-like solving approach will be able to utilize new rules because of theasymmetric boxes, and the Rule Based backtracking solver will have to take careof whichboxitiscurrentlyinsinceitcannoteasilybecalculatedbyassumedsymmetry.Some of these will allow the jigsaw sudoku to be solved faster and some will makethe solver slower.2http://en.wikipedia.org/wiki/File:A_nonomino_sudoku.svgChapter 3MethodsThe investigation we will do is to test the three algorithms on various diculties ofjigsaw sudokus to nd out how they compare to each other in terms of computationtime. We will also investigate how the solving time depends on the the number ofboxesthattherowsaandcolumnsintersectwithsincethiswill bethemajordierence between the two puzzles.3.1 Measuring timeWe start measuring time just before we compute the solutions with the dierentalgorithms and stop the measuring at the end of the program. We chose to usethe gettimeofday() function from the time.h [2] library to measure time. We choseto measure in microseconds since we gured milliseconds would be too inexact andnanoseconds would be too exact and introduce too much noise.All the measurements were performed at the same time and on the same hardwarein order to prevent external software to interfere with the results.3.2 Comparison setupWe got all of our puzzles for both sudoku and jigsaw sudoku from the same place [1].Because we chose to compare the runtime of the algorithms on sudoku and jigsawsudoku with regard to the diculty of the puzzles, we needed to get all puzzlesfrom the same website to ensure that the denition of diculty did not change.In total we used ve of each puzzle type and diculty, then we took the averageruntime to solve these for each algorithm. There were three diculties in totalwhich were easy, medium and hard.910 CHAPTER 3. METHODS3.3 AlgorithmsRule Based backtrackingThe rst algorithm we choose was the Rule Based backtracking way. The algorithmsimply goes through each possible number and checks if its valid to place it in thenext cell. If no number could be placed in the cell, the algorithm backtracks to theprevious cell and tries a new number there.This goes on until the nal cell has been lled. This algorithm will look almost thesame for both types of sudokus.An example can be seen in Appendix A where we show one step of the backtrackingalgorithm on a 4x4 sudoku. Even though the dimensions dier the principles forsolving a 9x9 sudoku are exactly the same. Keep in mind that the dimensions ofthe boxes in the example are only 2x2.Human-Like solvingWe based our humanlike solving algorithm on how a human would try to solve thejigsaw sudoku. This means we try to emulate the tactics and moves a human woulduse to nd all the numbers of a sudoku board. A better description of each stepcan be found in Appendix A.The objective of the algorithm is to eliminate the numbers in the cells by applyingrules until only one number remains in the cell. Then we ll out the cell with theremaining number and continue until all the numbers have been lled out.The algorithm works by iterating through the steps described in Appendix A, andwhenever a step is applied, it jumps back the start of the loop and start searchingforastepthatcanbeapplied. If nostepscouldbeapplieditmeanswehaveexhausted the possible steps and we then solve the remaining cells with our backtracking algorithm.Dancing LinksDancing Links is a variation of the exact cover algorithm developed by Knuth[3].The exact cover problem is a problem where, given a sparse matrix, is there a wayto choose rows from the matrix so that we have a new matrix where each row hasexactly one 1 in each column?Knuth devised an algorithm called Algorithm X[3] to solve this problem[11].While Algorithm X does nd a solution the algorithm is naive and the problem isNP-Complete. Thus the approach is not very eective.What Knuth did was that he implemented a fast heuristic to solve this problemusing two doubly linked list to represent the sparse matrix.This allowed for fast insertion and removal of the nodes since every node in thelinked list held information about which nodes it had previously been connectedtoo. It also removed the need to check every cell in the row to see if a column already3.3. ALGORITHMS 11was covered or was going to be covered, thus speeding up the process signicantly.The Dancing links algorithm is a constraint algorithm, so we will need to be able torepresent the sudokus and the jigsaw sudoku has some form of constraint problemusing a sparse matrix.A more in-depth explanation of how the Dancing Links algorithm can be found inAppendix A.How will the sparse matrix look for the sudokus?First we need to identify what the constraints are that we need to have fullled forthe sudoku to be solved, and in our case the constraints are the rules of the gameFor the rst rule we will need 81 columns to represent the total number of cells inour standard 9x9 sudoku.For the second rule there will be 9 rows and each row can hold 9 numbers whichgives a total of 81 columns.The third rule has 9 columns and each column can hold 9 numbers which gives atotal of 81 columns.The fourth rule gives 9 boxes with 9 numbers in each which gives us 81 columns.Thus our sparse matrix will be 324 columns wide.And since we will need one row for each cell and one for each number in the cell,we will get 81*9 rows which will be 729 rowsThis makes the total size of the sparse matrix for a standard sudoku 324x729[12]How will the sparse matrix dier between jigsawsudoku and normalsudoku?Since the the rules are exactly the same for both types of problems the sparse matrixwill have exactly the same amount of rows needing to be satised. The dierencewill be in how we present the possible solutions in the boxes. The normal sudokuwill have regular patterns in the box constraint columns while the jigsaw sudokuwill be irregular in its patterns.Chapter 4Results4.1 Hardware usedOperating System: Ubuntu 12.04 LTSMemory: 3.8 GiBProcessor: Intel Core2 Quad CPU Q9550 @ 2.83GHz 4OS type: 64-bitDate: April 12th, 2014Location: Computer lab red (rd), kth4.2 Average time of sudokus (s)Dancing LinksSudoku 1 2 3 4 AverageEasy 5396 4496 6204 5529 5406Medium 6810 4266 6337 5396 5702Hard 5029 4643 7090 6536 5824Rule-Based backtrackingSudoku 1 2 3 4 AverageEasy 61 77 860 4441 1359Medium 1249 162 86 394 472Hard 1414 2570 472 2545 17501314 CHAPTER 4. RESULTSHuman-Like solvingSudoku 1 2 3 4 AverageIntersections 54 54 54 54 54Easy 253 249 359 449 327Medium 531 147 443 399 380Hard 430 371 322 564 4214.3 Average time of jigsaw sudoku (s)Dancing LinksSudoku 1 2 3 4 AverageEasy 5250 4863 5598 5647 5564Medium 6600 3793 7060 6465 5979Hard 6081 5794 6871 5316 6015Rule-Based backtrackingJigsaw sudoku 1 2 3 4 AverageEasy 154 114 236 126 157Medium 16977 741 35056 83140 33987Hard 31166 23577 1125 53935 27450Human-Like solvingJigsaw sudoku 1 2 3 4 AverageIntersections Easy 70 76 68 70 71Easy 454 320 491 323 397Intersections Medium 80 72 66 62 70Medium 974 374 720 486 638Intersections Hard 74 70 68 80 73Hard 246 430 706 785 5414.4. COMPARISON BETWEEN JIGSAW SUDOKU AND NORMAL SUDOKU 154.4 Comparison between jigsaw sudoku and normal sudokuPerformance on jigsaw sudokuEasy Medium Hard010,00020,00030,000Runtime(s)Dancing LinksHuman Like SolvingRule Based BacktrackingPerformance on normal sudokuEasy Medium Hard02,0004,0006,000Runtime(s)16 CHAPTER 4. RESULTS4.5 DiscussionDancing LinksThe Dancing Links algorithm was the most consistent of all algorithms. Howeverit was not very eective compared to the human like solving. This is because thesolving speed of the Dancing Links algorithm is not aected by the diculty by thesudoku but by the size of the sparse matrix it uses.Human like solvingThis algorithm outperformed every other one except for the easy jigsaw case wherethe rule base backtracking did better.One interesting thing to note is that the algorithm solved the hard jigsaw sudokusfaster then it did solve the medium. This most likely has to do with the fact thatthe hard sudokus had more box intersections for the rows and columns which al-lowed for more eective techniques to be used.Rule Based BacktrackingBy far the most inconsistent algorithm in terms of solving speed. This has to dowith the fact that the harder the sudokus get, the bigger the chance that it recursesdown the wrong branch gets. This causes a lot of backtracking to occur an thusthe algorithm takes a long time to nish.This is also why we see results such as hard jigsaw sudoku 3, where it only tookabout 1125 s, which is less then a twentieth of any other result it got for hardjigsaws. It most likely takes a path that results in little backtracking and thus afast solving speed.4.6 Self-criticismAlthough the results tell a lot about how the dierent algorithms performs on thedierent kinds of sudokus, they are far from perfectly implemented. There is likelysome performance enhancements that can be done to trim time o the algorithmsolving speed.The denition of what makes a sudoku dicult is also not very strictly dened.What we did was that we used the same page for all our sudokus[1] so that wewould have a consistent denition. However this does not guarantee that the waythat the website denes it is the best way.There could also have been a bigger selection of sudokus since we now only testfor four of each diculty. This means the rule based solver could just as well havegotten four easy ones and outperformed the human like solver which might haveproduced another result completely.4.7. CONCLUSION 174.7 ConclusionBy looking at the results and comparing the solving time it becomes obvious thatthe human like solving approach is the fastest solver with few exceptions. The rulebased backtracking did outperform it sometimes but this was most likely due toluck with the recursion path.The Dancing Links algorithm did perform consistently but it could never get to thesame speed as the human like solver.Chapter 5Appendix A5.1 Rule Based Backtracking1http://bitcook.de/wp-content/uploads/2013/10/2x2_sudoku_backtracking1-300x245.pngFigure 5.1: Backtracking procedure, based on image from1.1920 CHAPTER 5. APPENDIX A1. This is the rst step we check in the backtracking algorithm. Here we haveplaced a 1 in cell (2,1). However this breaks 3 and 4. Thus we backtrack tothe previous state and try to place another number in the cell.2. We now try to place a 2 in cell (2,1) which will break rule 4 and thus triggerbacktracking to the previous state.3. Here we try to place a 3 in cell (2,1) which we nd does not break any of therules and thus is a valid move.4. The four is not visited here since we go down the branch in number 3. Wouldall the branches from step 3 turn out to be faulty we will continue to step 4.5. Since we lled a number in (2,1) we now move on to (2, 2) and try to placea 1 there which as it turns out breaks rule 4.6. So we go back to the previous state (3) in which we now try to place a 2instead in (2, 2). This breaks rule 3.7. We backtrack again and try to place a 3 in (2,2). This breaks rule 2 andtriggers a backtrack back to step 3.8. Here we place a 4 in (2,2) which follows all the rules.This continues until either we ll out the last cell or there is no steps left to try.If we managed to ll all the cells we are done, else the sudoku does not have asolution.5.2. HUMAN-LIKE SOLVING 21Figure 5.2: A jigsaw sudoku board with all its candidate numbers, based on imagefrom1.5.2 Human-Like SolvingTheveryrstthingwedoistoll outthesudokuboardwithall thepossiblecandidates, see g 5.2. In the begining, before applying any steps, every cell thatdoesnt have a clue has every number as its possible candidates.1. Check if there is a cell with only one solutionThis rule iterates through all the cells and checks if there is a cell with onlyone candidate for it. If so is the case then ll that cell out with the number.If the last cell has been lled, then were done. See gure 5.3.2. Remove impossible candidatesAfter we have lled out the new cells with numbers there might be candi-datesinsquaresthatarentvalidanymore. Thisisdonebyapplyingthejigsaw sudoku rules which are as follows:a)Every number has to show up exactly once in the nonomino.b)Every number has to show up exactly once per row.1http://www.sudokuwiki.org/jigsaw.htm22 CHAPTER 5. APPENDIX Ac)Every number has to show up exactly once per column.Thus if theres candidates to be removed, we do so and jump back to stepone, else continue to step three.3. Search for unique candidate numbersIn this step the algorithm iterates over all the nonominoes, rows and columnsto see if theres a candidate number that occurs only once in any of them.If thats the case, ll those out and jump back to step one, or if no singlenumbers are found, continue to step four. See gure 5.4.4. Find conjugate pairsSince there was no unique numbers in step three, we check if the rows, columnsand nonominoes if theres two cells that has exactly two identical candidatenumbers. If thats the case, we know that these two numbers has to be inthese two cells, meaning we can remove all other candidate numbers on thesame row, column or nonomino that these cells occur in. If no such occurrencewas found, continue to step ve, else go back to step one. See gure 5.5.5. Pair removalInthisstepweexamineeachnonominotoseeiftheresanytwoorthreeof the same candidate numbers aligned on the same row or column. If theseare the only possible placements of the candidate then we know that therecannot be any other of the same candidate aligned with these numbers on therow or the column, thus those numbers can be removed. See gure 5.6.6. Intersection removalTheintersectionremoval stepconsistsof twosub-stepswhicharethefol-lowing:a)Pair or triple in a box:b)Box Line ReductionThe rst move is to ll out the board with all the possible candidate numberswhich can be seen in g. 5.7-5.8.7. Double pairs [7]Because the nonominoes looks so dierent from each other we might some-times nd that by comparing two rows, or two columns in the same way asin step ve. If were lucky, we might be able to deduce that theres only twopossible rows to place the number in and thus be able to remove two rows ofthe candidate number in a nonomino. See gure 5.9.5.2. HUMAN-LIKE SOLVING 238. Double boxes [8]Like the box reduction technique we here check if theres a row or columnpassing through the with the modication that instead of only checking onerow or column we check two at a time to see if we might be able to removecandidate numbers from multiple boxes at a time. See gure 5.10.9. Law of Leftovers [9]Here we separate an equal amounts of nonominoes and an columns or rows.Then we draw a line through those columns an look which of the nonominocells sticks out of the enclosed coloumn/rows. Those cells must have the samevalues. See gure 5.11.10. Check if we are doneIf we have reached this far, either we are done or we need to use the back-tracking approach.11. BacktrackingIf we have reached this point in the algorithm that means theres no moremove to make. To circumvent this problem we simply solve the last remain-ing cells by applying the backtracking algorithm on the sudoku. Since theremaining cells are usually very few the backtracking has minimal eect onthe performance of the algorithm.24 CHAPTER 5. APPENDIX AFigure 5.3: Last candidate, based on image from1.Figure 5.4: Last in a row, based on image from1.Figure 5.5: Conjugate pairs, based on image from1.1http://www.sudokuwiki.org5.2. HUMAN-LIKE SOLVING 25Figure 5.6: Pair removal, based on image from1.Figure 5.7: Pair in a box, based on image from1.26 CHAPTER 5. APPENDIX AFigure 5.8: Box reduction, based on image from1.5.2. HUMAN-LIKE SOLVING 27Figure 5.9: Double pointing pairs, based on image from1.28 CHAPTER 5. APPENDIX AFigure 5.10: Double boxes, based on image from1.5.2. HUMAN-LIKE SOLVING 29Figure 5.11: Law of leftovers, based on image from1.30 CHAPTER 5. APPENDIX A5.3 Dancing LinksAlgorithm X1. Pick an unsatised constraintStart by nding a column that has not yet been covered2. Pick a row that satises that constraintThen choose a row that will cover that column3. Add the row to the solution setSince we have chosen a row to be part of our new solution matrix we addit to the set of rows in the solution4. Delete all rows that satisfy the constraints satised by the chosen rowSince we are only allowed one occurrence in each row we delete all rows thatshares columns with the added row5. 5-9. Repeat previous steps. . .6. . . .7. . . .8. . . .9. . . .10. No rows leftNow we have reached a point where all the constraints are not satised butwe have no rows left to add that satisfy that constraint. This will trigger abacktrack to the last step and try to nd a new solution from there. This iscalled uncovering a column.5.3. DANCING LINKS 31Figure 5.12: Picking unsatised constraint, based on image from1.Figure 5.13: Adding a row to the solution set, based on image from1.1http://www.sudokuwiki.org32 CHAPTER 5. APPENDIX AFigure 5.14: Picking unsatised constraints, based on image from1.Figure 5.15: Adding a row to the solution set, based on image from1.Figure 5.16: Backtracking, based on image from1.5.3. DANCING LINKS 33Figure 5.17: A Dancing Links matrix based on a gure from2.Dancing LinksThe Dancing Links rst need to construct the doubly linked list that its goingto operate on. This can be seen in g 5.3 where the top nodes represents thecovered columns and the number inside the boxes is the number of possiblecandidates they have for covering them.The extra node to the left of the top nodes is the header node. This is thereto keep track of when the matrix has been covered since that will mean itpoints to itselfThe boxes without numbers represents the candidates in the matrix for cov-ering columns, and the lines going to and from them is the pointers in thedoubly linked list.2http://garethrees.org/2007/06/10/zendoku-generation/dancing-links-1.png34 CHAPTER 5. APPENDIX AFigure 5.18: Covering a column, based on a gure from3.The Dancing Links basically consists of the following operations on the doulbylinked listCoverAs can be seen in g 5.4JustlikeintheAlgorithmXacolumniscoveredbyaddingarowtothesolution set and then removing all the conicting nodes on a row. This isdone by re-adjusting the pointers in the double linked list so that the toprow now points to the next available node in the matrix. The red arrowsrepresent the changed pointer. Notice that the nodes still retain pointers tothe removed nodes.3http://garethrees.org/2007/06/10/zendoku-generation/dancing-links-2.png5.3. DANCING LINKS 35Figure 5.19: Uncovering a column4.UncoverAs can be seen in g 5.5When uncovering a column with Dancing Link you just undo what you did inthe cover step in the exact reverse order. This can easily be done since nodesretained a pointer to their old nodes which makes it so that all you have todo is re-connect them.4http://garethrees.org/2007/06/10/zendoku-generation/dancing-links-2.pngBibliography[1] http://www.sudokuonline.com/play_jigsaw.phpcollected 2014-04-10[2] http://pubs.opengroup.org/onlinepubs/000095399/basedefs/sys/time.h.htmlcollected 2014-03-26[3] DancingLinks, DonaldE. Knuth, StanfordUniversity, 15november 2000,arXiv:cs/0011047,http://arxiv.org/abs/cs/0011047,[4] sudoku.http://www.ne.se/lang/sudoku,Nationalencyklopedin,collected 2014-03-05.[5] Aktuellaord2005.http://www.ne.se/rep/aktuella-ord-2005,Nationalencyklopedin,collected 2014-03-05.[6] http://www.sudocue.net/guide.php,collected 2014-04-01[7] http://www.sudokuwiki.org/Double_Pointing_Pairs,collected 2014-04-01[8] http://www.sudokuwiki.org/Double_Line_Box_Reduction,collected 2014-04-05[9] http://sudopedia.enjoysudoku.com/Law_of_Leftovers.html,collected 2014-04-05[10] http://bitcook.de/backtracking-method/,collected 2014-04-05[11] http://garethrees.org/2007/06/10/zendoku-generation/#section-4,collected 2014-04-053738 BIBLIOGRAPHY[12] http://www.stolaf.edu/people/hansonr/sudoku/exactcovermatrix.htm,collected 2014-04-05