Popular Python recipes tagged "sudoku"http://code.activestate.com/recipes/langs/python/tags/sudoku/2012-09-14T17:07:50-07:00ActiveState Code RecipesSudoku Game Generator (Python)
2012-09-14T17:07:50-07:00J W Jhttp://code.activestate.com/recipes/users/4181154/http://code.activestate.com/recipes/578250-sudoku-game-generator/
<p style="color: grey">
Python
recipe 578250
by <a href="/recipes/users/4181154/">J W J</a>
(<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sudoku/">sudoku</a>).
Revision 3.
</p>
<p>Outputs difficult games with solutions.</p>
Super 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&feature=autoplay&list=PL6B940F08B9773B9F&playnext=1" rel="nofollow">http://www.youtube.com/watch?v=bjObm0hxIYY&feature=autoplay&list=PL6B940F08B9773B9F&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>
Simple Sudoku (Python)
2011-06-02T14:15:02-07:00amir naghavihttp://code.activestate.com/recipes/users/4177294/http://code.activestate.com/recipes/577716-simple-sudoku/
<p style="color: grey">
Python
recipe 577716
by <a href="/recipes/users/4177294/">amir naghavi</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/oo/">oo</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/sudoku/">sudoku</a>).
Revision 10.
</p>
<p>This is a simple sudoku game.</p>
Sudoku solver in functional-programming style (Python)
2010-04-23T12:35:13-07:00Arnau Sanchezhttp://code.activestate.com/recipes/users/4173270/http://code.activestate.com/recipes/577188-sudoku-solver-in-functional-programming-style/
<p style="color: grey">
Python
recipe 577188
by <a href="/recipes/users/4173270/">Arnau Sanchez</a>
(<a href="/recipes/tags/functional/">functional</a>, <a href="/recipes/tags/recursion/">recursion</a>, <a href="/recipes/tags/sudoku/">sudoku</a>).
Revision 10.
</p>
<p>A simple brute-force Sudoku solver written in functional-programming style. This code is not aimed for speed, the goal is to write a clear, compact and (hopefully) pedagogical functional solution.</p>
Brute-force sudoku solver (Python)
2009-04-23T18:33:56-07:00Sylvain Fourmanoithttp://code.activestate.com/recipes/users/4150902/http://code.activestate.com/recipes/576725-brute-force-sudoku-solver/
<p style="color: grey">
Python
recipe 576725
by <a href="/recipes/users/4150902/">Sylvain Fourmanoit</a>
(<a href="/recipes/tags/sudoku/">sudoku</a>).
Revision 4.
</p>
<p>This is a very simple, short Sudoku solver using a classic brute-force approach.</p>
<p>What makes it nice is the purely arithmetic one-liner computing the constraint c (the sequence of already used digits on the same row, same column, same block of a given cell).</p>
Sudoku solver/creator (Python)
2008-09-12T00:18:27-07:00Collin Stockshttp://code.activestate.com/recipes/users/4149235/http://code.activestate.com/recipes/576505-sudoku-solvercreator/
<p style="color: grey">
Python
recipe 576505
by <a href="/recipes/users/4149235/">Collin Stocks</a>
(<a href="/recipes/tags/just_for_fun/">just_for_fun</a>, <a href="/recipes/tags/puzzle/">puzzle</a>, <a href="/recipes/tags/sudoku/">sudoku</a>).
</p>
<p>This program can solve and create sudoku puzzles</p>