Latest recipes tagged "recurssion"http://code.activestate.com/recipes/tags/recurssion/new/2012-06-23T14:56:05-07:00ActiveState Code RecipesSuper Simple Sudoku Solver in Python source code (Python) 2012-06-23T14:56:05-07:00David Adlerhttp://code.activestate.com/recipes/users/4182015/http://code.activestate.com/recipes/578140-super-simple-sudoku-solver-in-python-source-code/ <p style="color: grey"> Python recipe 578140 by <a href="/recipes/users/4182015/">David Adler</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/recursive/">recursive</a>, <a href="/recipes/tags/recurssion/">recurssion</a>, <a href="/recipes/tags/sodoku/">sodoku</a>, <a href="/recipes/tags/sudoku/">sudoku</a>). Revision 5. </p> <p>A simple algorithm which uses a recursive function to solve the puzzle.</p> <hr /> <p>THE ALGORITHM</p> <p>The credit for this algorithm must go to Richard Buckland: <a href="http://www.youtube.com/watch?v=bjObm0hxIYY&amp;feature=autoplay&amp;list=PL6B940F08B9773B9F&amp;playnext=1" rel="nofollow">http://www.youtube.com/watch?v=bjObm0hxIYY&amp;feature=autoplay&amp;list=PL6B940F08B9773B9F&amp;playnext=1</a></p> <p>Takes a partially filled in grid, inserts the min value in a cell (could be a random cell, in this case the first free cell). If the min value is not legal it will increment until the max value is reached (number 9), checking each time if the incremented value is legal in that cell (ie does not clash with any already entered cells in square, col or row). If it is legal, it will call itself (the hasSolution function) thus using this slightly more filled in grid to find a new cell and check which value is legal in this next cell. If no values are legal in the next cell, it will clear the previous grid entry and try incrementing the value.</p> <p>isLegal = does not conflict with any other numbers in the same row, column or square</p>