<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Sudoku</title>
		<link>http://www.allegro.cc/forums/view/586529</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 26 Jul 2006 23:51:35 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Originally only for private use within the sudoku wave here in Germany ( for my gf ) I have coded my own sudoku version. I have tried to give it a professional look. Now I will release it after some additional polish such as more sodukos. I would also be nice to add a sudoku solver, but that is another story. How many of you play sudoku ( = would be also interested in contributing your own sudokus and testing it )?</p><p>Here a shot:</p><p>http://www.jray.de/sudoku.JPG</p><p>[EDIT]<br />Fixed typos.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mordredd)</author>
		<pubDate>Tue, 18 Jul 2006 13:56:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I enjoy solving difficult sudokus during boring breaks or travel. Given the difficulty and the minimum amount of time I spend on it (some times as little as 5 minutes a day), a sudoku can take me a few weeks to solve it.</p><p>However, I prefer the paper version.</p><p>As to the &quot;new sudoku&quot; part: Have you tried the sudoku generator? That&#39;d give you nearly infinite supply of puzzles.</p><p><i>edit:</i> fixed grammar.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Indeterminatus)</author>
		<pubDate>Tue, 18 Jul 2006 14:53:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am a Sudoku player too, and I&#39;ve already written a Sudoku generator, but now it crashes all the time ...<br />Otherwise I would have given you my source code for it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michael Faerber)</author>
		<pubDate>Tue, 18 Jul 2006 17:21:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I normally play Sudoku whenever I&#39;m in my classroom, and bored...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Lucid Nightmare)</author>
		<pubDate>Tue, 18 Jul 2006 23:00:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have written a solver (actually quite easy) , but no generator</p><p>[url <a href="http://mattsmith.allegronetwork.com/java/Sudoku.html][/url">http://mattsmith.allegronetwork.com/java/Sudoku.html][/url</a>]
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matt Smith)</author>
		<pubDate>Wed, 19 Jul 2006 01:43:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have a solver that was originally based on simple bit manipulations. This is enough for simple Sudoku&#39;s, but harder ones require non-local constraints to be recognised, and I wasn&#39;t sure how to implement those elegantly. I haven&#39;t worked on it for several months though... maybe I&#39;ll have a good idea if I have a new look at it.<br />The fun thing is that it used all constraints it could (conterary to solvers that start with simple patterns and only use more complex ones if the simpler ones fail), which meant that it solved those Sudoku&#39;s it could solve in a few (ten or less) sweeps.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Wed, 19 Jul 2006 01:53:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, here is download link for a demo version with a single, playable sudoku. If you ask yourself why there is this color rainbow fancy thingie: it is a feature that is not fully implemented yet. The idea is that you can set markers with different colors while pressing Ctrl and clicking left. But that does not work yet, though.</p><p><a href="http://www.jray.de/Sudoku.rar">http://www.jray.de/Sudoku.rar</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mordredd)</author>
		<pubDate>Wed, 19 Jul 2006 11:42:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re Sudoku doesn&#39;t run-</p><p><b>
SUDOKU caused an invalid page fault in
module ALLEG42.DLL at 0187:679eab65.
Registers:
EAX=00000000 CS=0187 EIP=679eab65 EFLGS=00010246
EBX=00000000 SS=018f ESP=0073fb10 EBP=0073fd28
ECX=00000000 DS=018f ESI=000000ff FS=3f47
EDX=000000ab ES=018f EDI=000000ff GS=0000
Bytes at CS:EIP:
ff 50 1c eb f2 8d b6 00 00 00 00 83 ec 0c 8b 44 
Stack dump:
000000ff 000000ff 0073fd28 00401ed8 00a71e90 00a71b20 00000000 00000000 00000027 00000026 00000013 0000001a 7801a8fd 00000009 7801a8e8 00000000 
</b></p><p><i>micah said:</i>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How <b>mnay</b> of you play sudoku ( = would be also interested in contributing your own sudokus and testing it )?
</p></div></div><p>

So you basically want sudoku examples, right?<br />They come up in the newspapers every day, solve them if you can and write them down, and put it into your sUdOkU <b>game</b>...</p><p><img src="http://www.allegro.cc/forums/smileys/angry.gif" alt="&gt;:(" /> <img src="http://www.allegro.cc/forums/smileys/angry.gif" alt="&gt;:(" /> <img src="http://www.allegro.cc/forums/smileys/angry.gif" alt="&gt;:(" /></p><p>      <a href="http://www.specialgratis.it/sfondi_L/paesaggi/natura/natur002.jpg">cough cough !@#$</a><img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" /><br /><b>Seems familiar?</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Lucid Nightmare)</author>
		<pubDate>Thu, 20 Jul 2006 21:54:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s very easy to write a Sudoku solver using a recursive algorithm. That way, it can find a solution to any possible Sudoku puzzle.</p><p>Goes about like this:
</p><div class="source-code snippet"><div class="inner"><pre>function solve<span class="k2">(</span>x,y<span class="k2">)</span>
<span class="n">1</span><span class="k2">)</span> insert number <span class="n">9</span> at the given position
<span class="n">2</span><span class="k2">)</span> check <span class="k1">if</span> the puzzle is still correct
<span class="n">3</span><span class="k2">)</span> no? insert number <span class="n">8</span>. check- no? insert number <span class="n">7</span>... <span class="k1">and</span> so on..
<span class="n">4</span><span class="k2">)</span> yes? look <span class="k1">for</span> the next blank field <span class="k1">and</span> recursively call solve<span class="k2">(</span>x,y<span class="k2">)</span> <span class="k1">for</span> the <span class="k1">new</span> position
</pre></div></div><p>

If 3) gives no for all numbers (there is no possible number for this field), the function just aborts. That way the recursive loop goes back to the last instance of the recursive function and tries the next number there.</p><p>If (x,y) points to the last field at 4), the Sudoku is solved and you should somehow completely terminate the recursive stuff (using a global variable, for example).</p><p>I once coded it that way and it could solve any Sudoku I put into it, even the &quot;hardest possible&quot; one I found at some Sudoku site. It may not be the fastest algorithm, but you can easily prove that it works for any Sudoku that has at least one solution.</p><p>And about your Sudoku game, Micah Crow:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I have tried to give it a professional look.
</p></div></div><p>
Professional usually means that you use real transparency. The method you use (dithering of fully transparent pixels with non-transparent pixels, or maybe it has some special name?) can only be found in some old 256-color games nowadays.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Simon Parzer)</author>
		<pubDate>Fri, 21 Jul 2006 00:51:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>A sudoku generator really isn&#39;t all that hard (especially if you have created a solver)  If you start with the fully solved Sudoku:</p><p>123 456 789<br />456 789 123<br />789 123 456</p><p>234 567 891<br />567 891 234<br />891 234 567</p><p>345 678 912<br />678 912 345<br />912 345 678</p><p>(Actually you could you any fully solved Sudoku, but I prefer to start from a logical state such as this.)</p><p>Then swap two columns within (1-3)(4-6)(7-9)  It wont work if you swap 1&amp;5 or 6&amp;7, etc.  Do the same thing for the rows.  Repeat as necessary.</p><p>Remove any one number.  If the Sudoku is still solvable with by your algorithm, good.  If not, put the number back.  For difficulty settings, just choose how many numbers you want to fully remove.</p><p>If source code would help, I have a complete Sudoku generator / solver written in Java (and highly commented at that).  Just email joshuaarogers@gmail.com
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Joshua Rogers)</author>
		<pubDate>Fri, 21 Jul 2006 08:47:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Simon Parzer said:</div><div class="quote"><p>

Professional usually means that you use real transparency. The method you use (dithering of fully transparent pixels with non-transparent pixels, or maybe it has some special name?) can only be found in some old 256-color games nowadays.
</p></div></div><p>

Ok, the reason is very simple. The font is white with grey or black outlines. I would use &quot;real&quot; transparency you would remark these outlines.  </p><p>[EDIT]</p><p>Notice the mousepointer which uses &quot;real&quot; transparency, because it does not have any outlines ( i.e. there is no need to make the color wheel contrastive to the background.</p><div class="quote_container"><div class="title">Lucid Nigthmare said:</div><div class="quote"><p>

So you basically want sudoku examples, right?<br />They come up in the newspapers every day, solve them if you can and write them down, and put it into your sUdOkU game...
</p></div></div><p>

Don&#39;t be mean only because I criticised you. Beside the point that we do not have any sudokus in our newspapers ( just in case that your answer was a serious one ) and that I am well able of solving sudokus I do not get the message behind the upper and lower case letters and the bold written word &quot;game&quot;. Could you explain that precisely, please?</p><p>Further, concerning the crash: What is your system config, desktop color depth and so on?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mordredd)</author>
		<pubDate>Fri, 21 Jul 2006 13:25:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Checked it on two computers (mine and my friends). Crashed on both. <br />Config(Mine): Win98SE, 24 bit<br />Config(Friend): WinXP, 24 bit
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Lucid Nightmare)</author>
		<pubDate>Fri, 21 Jul 2006 21:39:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hm that is strange. I must have to do with the 24 bit color depth, although I do the following:</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/set_color_depth" target="_blank"><span class="a">set_color_depth</span></a><span class="k2">(</span> <a href="http://www.allegro.cc/manual/desktop_color_depth" target="_blank"><span class="a">desktop_color_depth</span></a><span class="k2">(</span><span class="k2">)</span> <span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

Has anyone else tested it with 24 bit color depth? ( I can&#39;t because my GeForce does only allow 16/32... )
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mordredd)</author>
		<pubDate>Sat, 22 Jul 2006 01:49:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I once coded it that way and it could solve any Sudoku I put into it, even the &quot;hardest possible&quot; one I found at some Sudoku site.
</p></div></div><p>

I&#39;m surprised.  Maybe you didn&#39;t try enough puzzles.  The problem with the basic backtracking approach is that it can easily get trapped down one branch of the search tree which won&#39;t lead to any solutions, or it retries a lot of the same sort of board configurations with only minor variations which won&#39;t lead to solutions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Sat, 22 Jul 2006 04:12:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The problem with the basic backtracking approach is that it can easily get trapped down one branch of the search tree which won&#39;t lead to any solutions,
</p></div></div><p>
Uh... Isn&#39;t the point of the backtracker that it can get out of such situations?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Wetimer)</author>
		<pubDate>Sat, 22 Jul 2006 08:58:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think the problem is that it can take far too long for a brute-force algorithm to get out of such dead-ends.<br />Anyway, writing a brute-force Sudoku solver isn&#39;t really that challenging... writing one that solves by logic alone is far more interesting.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 22 Jul 2006 11:41:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Or you can mix both brute and logic together...?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Lucid Nightmare)</author>
		<pubDate>Sat, 22 Jul 2006 12:56:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Every solver must have brute force to some extent. When one solves by hand a sudoku of the highest difficulty degrees, one often has to make guesses and run into dead ends, then return. This is kind of brute force, right? When an algorithm reaches a point, where no obvious numbers can be added, it could either continue with brute force guessing, or one could come up with an even deeper analysis of the situation. But is it proved that an algo must exist for every situation? As I see it, those presumptive algos would be so complicated <i>and so many</i> that one could almost think of them as brute force. Or anyhow, at some point brute force is the most economic solution.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Sat, 22 Jul 2006 13:15:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Every solver must have brute force to some extent.
</p></div></div><p>
Not at all! That is to say, if the puzzle is properly constructed, then you never <i>need</i> to guess.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
When one solves by hand a sudoku of the highest difficulty degrees, one often has to make guesses and run into dead ends, then return.
</p></div></div><p>
It should not be <i>nescessary</i>, but it can be easier than spotting the pattern that constrains what the correct moves are.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
This is kind of brute force, right?
</p></div></div><p>
Yes. Brute force (in this context) means try every move and pick the best one (ie, the one that leads to the solution).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
But is it proved that an algo must exist for every situation?
</p></div></div><p>
I think so, yes. But you have to combine all non-local constraints, which can be very hard.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
As I see it, those presumptive algos would be so complicated and so many that one could almost think of them as brute force.
</p></div></div><p>
If they don&#39;t involve guessing, then it&#39;s not brute force.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Or anyhow, at some point brute force is the most economic solution.
</p></div></div><p>
Oh, definately: if logic does not work, guess on one of the most constraint squares and try again is definately easier and possibly more economic. It&#39;s not the challenge though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 22 Jul 2006 13:48:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, you could speed up the brute force algorithm by weeding down all of the easy choices first. Create an array of flags, turn off flags for every number that cannot occupy a given square, find first square with only one flag set, set the square to that number, and repeat until no &quot;single&quot; flag can exist.  At this point, you could create a tree with possible solutions and you should have a significantly less troublesome time (at least time wise) finding the solution.  Heck, on some easier puzzles, you won&#39;t even need to do this, you could solve it by marking the squares alone...</p><p>Then again, if one was to read up on common sudoku solving strategies, the whole brute force create-a-tree-to-find-the-solution step could be replaced with more &quot;elaborate&quot; logical mechanisms for filling in the gaps.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Carrus85)</author>
		<pubDate>Sat, 22 Jul 2006 13:54:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
if the puzzle is properly constructed, then you never need to guess.
</p></div></div><p>
So one can always use some flag algo that in any sudoku with only one solution, in any situation, always finds at least one space with only one possible number. Like:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">do</span>
   zeroflag_all_impossible<span class="k2">(</span>my_sudoku<span class="k2">)</span><span class="k2">;</span>
   set_the_numbers_in_all_spaces_with_only_one_flag<span class="k2">(</span>my_sudoku<span class="k2">)</span><span class="k2">;</span>
<span class="k1">while</span> <span class="k2">(</span>my_sudoku-&gt;not_ready<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

As I see it, a properly constructed sudoku only has to fulfill the requirement that it has only one solution. Not requiring the solver to make guesses is in itself not a requirement for a properly constructed sudoku. I mean, even if the sudoku requires guessing, it might still have only one solution and therefore it would be properly constructed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Sat, 22 Jul 2006 16:12:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I mean, even if the sudoku requires guessing, it might still have only one solution and therefore it would be properly constructed.
</p></div></div><p>
I don&#39;t think that&#39;s true, I think a sudoku that has exactly one solution can never require a guess, but I lack the mathematical skill to even attempt to prove it.<br />I think you only need to guess if you fail to recognise some pattern (higher order swordfish, say) that tells you that some numbers are impossible. A human may very well detect such a pattern more easily by trial and error, but computers are not human.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 22 Jul 2006 16:20:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You don&#39;t think it&#39;s true, I do think it&#39;s true. Let&#39;s wait for a mathematical proof. I kind of wish I&#39;m wrong. But what I tried to explain was that the qualities of the definite algo might be so complex that it might be hard to distinguish it from brute force and guessing.</p><p>I mean, consider the flagging thing. First you set all nine flags of one empty space. Then you check all other spaces in that room and reset flags. Then you check all other spaces in same row, then ditto for same column. Well, when you first set the flags, you <i>kind of</i> guessed that all nine numbers were possible. Then, after some restraining zeroflagging, you <i>kind of</i> guessed that this or that number is the right number, and so on. These are not real guesses, but the more complex the algo is, the more you might have to deal with logic branches that could be considered guesses.</p><p>For instance, you can check if three particular free cells have the same three flags, meaning these three corresponding numbers cannot occure in any other free cell in that room, column or row. Well, checking all combinations of three free cells might result in no result. So this whole branch has been a dead end, just like guessing that one free cell might be 9.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Halmén)</author>
		<pubDate>Sat, 22 Jul 2006 16:49:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think that even if you solve it using logic you still need an algorithm to search for the appropriate solution. As Johan said I think it requires back-tracking when searching for said solution. I&#39;ve got no proof either though so it&#39;s up for debate. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kentl)</author>
		<pubDate>Sat, 22 Jul 2006 18:30:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If a Sudoku gets to the point where no more numbers can be figured out (assuming it isn&#39;t finished at this point) then the puzzle has more than one solution.  Something that a self-respecting Sudoku creator would not do.</p><p>The idea with the flags is correct.  It&#39;s a good approach.  I&#39;ve built a solver / builder in Java using that approach.  It takes only a second to solve the puzzle.  Good thinking on the part of whoever suggested it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Joshua Rogers)</author>
		<pubDate>Sat, 22 Jul 2006 20:55:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So you&#39;ve built a Sudoku-solver which doesn&#39;t need to do any form of search? In each step it always knows what to do without looking at future steps (ie seatch)? Care to fill us in on how it works? And perhaps point us to your solver if its available on the net? It would be interesting material.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kentl)</author>
		<pubDate>Sat, 22 Jul 2006 21:00:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m not sure that I fully understand your question, but yes, I have built a solver.  For each square it keeps track of what it can be and what it can&#39;t be.  Simple deduction yields the answers.  Much in the same way that a human would.  No guessing is needed.</p><p>If you would like the program, just email me at joshuaarogers at gmail dot com.  (Notice there is an a between joshua and rogers).  I hope that it helps.  Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Joshua Rogers)</author>
		<pubDate>Sat, 22 Jul 2006 22:28:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My solver works by operating on bits: for each of the squares, bits are set for which numbers `may be&#39; there. For each column, row and mini-block we have the same. A sequence of logical ands and xors then eliminates impossible combinations, after which bitshifts and logical ors construct the new row and column bitfields, whichare used in the next iteration. It gets a bit more complicated if the constraints are non-local, in which case simple shifts no longer do the trick, at least not easily.<br />The advantage of the method is that it eliminates all unknowns that it can in one sweep, and automatically applies `difficult&#39; constraints as well as easier ones. It will either solve the puzzle in a split second in fewer than ten iterations, or fail in a similar number of iterations.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sun, 23 Jul 2006 02:09:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, it turns out that it happens quite often that you cannot solve a puzzle via pure &quot;flagging&quot; alone.  Take this example:</p><pre>
000|200|304
061|300|092
302|050|000
---+---+---
420|805|100
108|000|207
005|9X2|046
---+---+---
000|090|701
610|004|980
509|001|000

</pre><p>

It becomes quite obvious that the X should be the number 1.  Unfortunately, simply &quot;flagging&quot; what a blank can/cannot be doesn&#39;t provide you with a definate answer in this case, without doing a block uniqueness test. (Since it is the only square in the given block that can be the value 1, it must be the value 1).  Unfortunately, by simply marking the squares that cannot be one from the row/column/coexist on same block rules, you cannot deduce this without another step.</p><p>Of course, this is easily fixed by occasionally doing a uniqueness test for all of the squares and updating them accordingly.  But then you run into puzzles like this: (websudoku evil puzzle #8,873,319,999)</p><pre>
040|050|000
600|000|005
020|000|867
---+---+---
000|001|300
090|384|050
006|700|000
---+---+---
387|000|010
500|000|002
000|070|090
</pre><p>

The algorithm so far can only fill in the puzzle to this point, then dies because of a lack of information:
</p><pre>
040|050|000
600|000|005
025|000|867
---+---+---
050|001|300
090|384|050
036|705|000
---+---+---
387|000|010
509|000|002
000|070|090
</pre><p>

So, no, you cannot solve the puzzle simply by &quot;flagging&quot; possible solutions using the core rules.</p><p>Here is the python program I&#39;ve been using so far to solve the puzzles:
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#!/usr/bin/python -OO</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td><span class="p"># Sudoku Solver</span></td></tr><tr><td class="number">4</td><td><span class="p"># By Caleb Deveraux aka Carrus85</span></td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td><span class="p"># Note:  Currently doesn't solve the more difficult puzzles!</span></td></tr><tr><td class="number">7</td><td>&#160;</td></tr><tr><td class="number">8</td><td>import sys</td></tr><tr><td class="number">9</td><td>&#160;</td></tr><tr><td class="number">10</td><td>def block_iterator<span class="k2">(</span>coords, excludeSelf <span class="k3">=</span> False<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">11</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">12</td><td><span class="s">  Generates an in iterator over all of the elements of the block containing</span></td></tr><tr><td class="number">13</td><td><span class="s">  coords</span></td></tr><tr><td class="number">14</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">15</td><td>  row, column <span class="k3">=</span> coords</td></tr><tr><td class="number">16</td><td>  </td></tr><tr><td class="number">17</td><td>  row_bounds, column_bounds <span class="k3">=</span> <span class="k2">(</span><span class="n">0</span>,<span class="n">3</span><span class="k2">)</span>, <span class="k2">(</span><span class="n">0</span>,<span class="n">3</span><span class="k2">)</span></td></tr><tr><td class="number">18</td><td>  </td></tr><tr><td class="number">19</td><td>  <span class="k1">if</span> row <span class="k3">&gt;</span> <span class="n">2</span> <span class="k1">and</span> row <span class="k3">&lt;</span> <span class="n">6</span><span class="k2">:</span>  </td></tr><tr><td class="number">20</td><td>    row_bounds <span class="k3">=</span> <span class="k2">(</span><span class="n">3</span>,<span class="n">6</span><span class="k2">)</span></td></tr><tr><td class="number">21</td><td>  elif row <span class="k3">&gt;</span> <span class="n">5</span><span class="k2">:</span>    </td></tr><tr><td class="number">22</td><td>    row_bounds <span class="k3">=</span> <span class="k2">(</span><span class="n">6</span>,<span class="n">9</span><span class="k2">)</span></td></tr><tr><td class="number">23</td><td>&#160;</td></tr><tr><td class="number">24</td><td>  <span class="k1">if</span> column <span class="k3">&gt;</span> <span class="n">2</span> <span class="k1">and</span> column <span class="k3">&lt;</span> <span class="n">6</span><span class="k2">:</span>  </td></tr><tr><td class="number">25</td><td>    column_bounds <span class="k3">=</span> <span class="k2">(</span><span class="n">3</span>,<span class="n">6</span><span class="k2">)</span></td></tr><tr><td class="number">26</td><td>  elif column <span class="k3">&gt;</span> <span class="n">5</span><span class="k2">:</span>      </td></tr><tr><td class="number">27</td><td>    column_bounds <span class="k3">=</span> <span class="k2">(</span><span class="n">6</span>,<span class="n">9</span><span class="k2">)</span></td></tr><tr><td class="number">28</td><td>&#160;</td></tr><tr><td class="number">29</td><td>  <span class="k1">for</span> i in range<span class="k2">(</span>row_bounds<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>, row_bounds<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">30</td><td>    <span class="k1">for</span> j in range<span class="k2">(</span>column_bounds<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>, column_bounds<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">31</td><td>      <span class="k1">if</span> <span class="k2">(</span>i,j<span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> coords <span class="k1">and</span> excludeSelf:</td></tr><tr><td class="number">32</td><td>        <span class="k1">continue</span></td></tr><tr><td class="number">33</td><td>      yield i,j</td></tr><tr><td class="number">34</td><td>&#160;</td></tr><tr><td class="number">35</td><td>def puzzle_iterator<span class="k2">(</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">36</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">37</td><td><span class="s">  Generates an iterator over the entire puzzle</span></td></tr><tr><td class="number">38</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">39</td><td>  <span class="k1">for</span> i in range<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">40</td><td>    <span class="k1">for</span> j in range<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">41</td><td>      yield i,j</td></tr><tr><td class="number">42</td><td>&#160;</td></tr><tr><td class="number">43</td><td>def single_flag_iterator<span class="k2">(</span>flags<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">44</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">45</td><td><span class="s">  Iterates over flags, returning coordinates for any flags</span></td></tr><tr><td class="number">46</td><td><span class="s">  that only can take on one possible value</span></td></tr><tr><td class="number">47</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">48</td><td>  <span class="k1">for</span> i in puzzle_iterator<span class="k2">(</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">49</td><td>    <span class="k1">if</span> len<span class="k2">(</span> lookup<span class="k2">(</span>i, flags<span class="k2">)</span> <span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">1</span><span class="k2">:</span></td></tr><tr><td class="number">50</td><td>      yield i</td></tr><tr><td class="number">51</td><td>&#160;</td></tr><tr><td class="number">52</td><td>def row_iterator<span class="k2">(</span>coords, excludeSelf <span class="k3">=</span> False<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">53</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">54</td><td><span class="s">  Generates an iterator over the all of the items in coords' row</span></td></tr><tr><td class="number">55</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">56</td><td>  <span class="k1">for</span> i in range<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">57</td><td>    <span class="k1">if</span> <span class="k2">(</span>i,coords<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> coords <span class="k1">and</span> excludeSelf:</td></tr><tr><td class="number">58</td><td>      <span class="k1">continue</span></td></tr><tr><td class="number">59</td><td>    yield coords<span class="k2">[</span><span class="n">0</span><span class="k2">]</span>,i</td></tr><tr><td class="number">60</td><td>&#160;</td></tr><tr><td class="number">61</td><td>def column_iterator<span class="k2">(</span>coords, excludeSelf <span class="k3">=</span> False<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">62</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">63</td><td><span class="s">  Generates an iterator over all of the items in coords' column</span></td></tr><tr><td class="number">64</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">65</td><td>  <span class="k1">for</span> i in range<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">66</td><td>    <span class="k1">if</span> <span class="k2">(</span>i,coords<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> coords <span class="k1">and</span> excludeSelf:</td></tr><tr><td class="number">67</td><td>      <span class="k1">continue</span></td></tr><tr><td class="number">68</td><td>    yield i, coords<span class="k2">[</span><span class="n">1</span><span class="k2">]</span></td></tr><tr><td class="number">69</td><td>&#160;</td></tr><tr><td class="number">70</td><td>def lookup<span class="k2">(</span>coords, where<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">71</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">72</td><td><span class="s">  Performs a basic lookup when given a coords tuple (row, column)</span></td></tr><tr><td class="number">73</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">74</td><td>  <span class="k1">return</span> where<span class="k2">[</span>coords<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">]</span><span class="k2">[</span>coords<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">]</span></td></tr><tr><td class="number">75</td><td>&#160;</td></tr><tr><td class="number">76</td><td>def lookup_set<span class="k2">(</span>coords, where, what<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">77</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">78</td><td><span class="s">  Performs a lookup, setting the value of coords to what</span></td></tr><tr><td class="number">79</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">80</td><td>  where<span class="k2">[</span>coords<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">]</span><span class="k2">[</span>coords<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">]</span> <span class="k3">=</span> what</td></tr><tr><td class="number">81</td><td>&#160;</td></tr><tr><td class="number">82</td><td>def unique_entries<span class="k2">(</span>coords, flags<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">83</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">84</td><td><span class="s">  Returns the unqiue entries for a given coordinate on the board that</span></td></tr><tr><td class="number">85</td><td><span class="s">  no other entry in block containing said coord shares</span></td></tr><tr><td class="number">86</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">87</td><td>  <span class="k1">return</span> reduce<span class="k2">(</span> lambda x,y: x-y, <span class="k2">[</span>lookup<span class="k2">(</span>i, flags<span class="k2">)</span> <span class="k1">for</span> i in block_iterator<span class="k2">(</span>coords, True<span class="k2">)</span><span class="k2">]</span>, lookup<span class="k2">(</span>coords, flags<span class="k2">)</span> <span class="k2">)</span></td></tr><tr><td class="number">88</td><td>&#160;</td></tr><tr><td class="number">89</td><td>def uniqueify_block<span class="k2">(</span>coords, flags<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">90</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">91</td><td><span class="s">  Iterates over an entire block, performing uniqueness tests</span></td></tr><tr><td class="number">92</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">93</td><td>  <span class="k1">for</span> i in block_iterator<span class="k2">(</span>coords<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">94</td><td>    temp <span class="k3">=</span> unique_entries<span class="k2">(</span>i,flags<span class="k2">)</span></td></tr><tr><td class="number">95</td><td>    <span class="k1">if</span> len<span class="k2">(</span>temp<span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">1</span><span class="k2">:</span>      # <span class="k1">if</span> it turns out we can only take on one value due to uniqueness requirements,</td></tr><tr><td class="number">96</td><td>      lookup_set<span class="k2">(</span>i, flags, temp<span class="k2">)</span>  # set our set variable to a set containing only <span class="k1">this</span> value</td></tr><tr><td class="number">97</td><td>&#160;</td></tr><tr><td class="number">98</td><td>def uniqueify_all<span class="k2">(</span>flags<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">99</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">100</td><td><span class="s">  Quickly updates all of the items in every block using the uniqueness test</span></td></tr><tr><td class="number">101</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">102</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">0</span>,<span class="n">0</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Top-Left block</td></tr><tr><td class="number">103</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">0</span>,<span class="n">3</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Top-Center block</td></tr><tr><td class="number">104</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">0</span>,<span class="n">6</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Top-Right block</td></tr><tr><td class="number">105</td><td>  </td></tr><tr><td class="number">106</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">3</span>,<span class="n">0</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Left block</td></tr><tr><td class="number">107</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">3</span>,<span class="n">3</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Center block</td></tr><tr><td class="number">108</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">3</span>,<span class="n">6</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Right block</td></tr><tr><td class="number">109</td><td>&#160;</td></tr><tr><td class="number">110</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">6</span>,<span class="n">0</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Bottom-Left block</td></tr><tr><td class="number">111</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">6</span>,<span class="n">3</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Bottom-Center block</td></tr><tr><td class="number">112</td><td>  uniqueify_block<span class="k2">(</span> <span class="k2">(</span><span class="n">6</span>,<span class="n">6</span><span class="k2">)</span>, flags <span class="k2">)</span>      # Bottom-Right block</td></tr><tr><td class="number">113</td><td>&#160;</td></tr><tr><td class="number">114</td><td>&#160;</td></tr><tr><td class="number">115</td><td>def mark<span class="k2">(</span>coords, flags, value<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">116</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">117</td><td><span class="s">  Marks rows, columns and block entries so they cannot become</span></td></tr><tr><td class="number">118</td><td><span class="s">  value.</span></td></tr><tr><td class="number">119</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">120</td><td>  <span class="k1">for</span> i in row_iterator<span class="k2">(</span>coords<span class="k2">)</span><span class="k2">:</span>      # Mark Rows</td></tr><tr><td class="number">121</td><td>    lookup<span class="k2">(</span>i, flags<span class="k2">)</span>.discard<span class="k2">(</span>value<span class="k2">)</span></td></tr><tr><td class="number">122</td><td>&#160;</td></tr><tr><td class="number">123</td><td>  <span class="k1">for</span> i in column_iterator<span class="k2">(</span>coords<span class="k2">)</span><span class="k2">:</span>    # Mark Columns</td></tr><tr><td class="number">124</td><td>    lookup<span class="k2">(</span>i, flags<span class="k2">)</span>.discard<span class="k2">(</span>value<span class="k2">)</span></td></tr><tr><td class="number">125</td><td>&#160;</td></tr><tr><td class="number">126</td><td>  <span class="k1">for</span> i in block_iterator<span class="k2">(</span>coords<span class="k2">)</span><span class="k2">:</span>    # Mark Block</td></tr><tr><td class="number">127</td><td>    lookup<span class="k2">(</span>i, flags<span class="k2">)</span>.discard<span class="k2">(</span>value<span class="k2">)</span></td></tr><tr><td class="number">128</td><td>&#160;</td></tr><tr><td class="number">129</td><td>def update_flags<span class="k2">(</span>puzzle, flags<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">130</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">131</td><td><span class="s">  Updates all flags once.  Called only to initialize the flags</span></td></tr><tr><td class="number">132</td><td><span class="s">  to a default state.</span></td></tr><tr><td class="number">133</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">134</td><td>  <span class="k1">for</span> i in puzzle_iterator<span class="k2">(</span><span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">135</td><td>    value <span class="k3">=</span> lookup<span class="k2">(</span>i, puzzle<span class="k2">)</span></td></tr><tr><td class="number">136</td><td>    <span class="k1">if</span> value:          # <span class="k1">if</span> <span class="k1">this</span> point on the puzzle has been specified</td></tr><tr><td class="number">137</td><td>      lookup_set<span class="k2">(</span>i, flags, set<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span>    # assign it the empty set</td></tr><tr><td class="number">138</td><td>      mark<span class="k2">(</span>i, flags, value<span class="k2">)</span>      # <span class="k1">and</span> update markings</td></tr><tr><td class="number">139</td><td>  uniqueify_all<span class="k2">(</span>flags<span class="k2">)</span>          </td></tr><tr><td class="number">140</td><td>&#160;</td></tr><tr><td class="number">141</td><td>&#160;</td></tr><tr><td class="number">142</td><td>def solve<span class="k2">(</span>puzzle<span class="k2">)</span><span class="k2">:</span></td></tr><tr><td class="number">143</td><td>  <span class="s">""</span><span class="s">"</span></td></tr><tr><td class="number">144</td><td><span class="s">  Solves the given puzzle.</span></td></tr><tr><td class="number">145</td><td><span class="s">  0's are treated as empty blanks.</span></td></tr><tr><td class="number">146</td><td><span class="s">  </span></td></tr><tr><td class="number">147</td><td><span class="s">  Note: May return an unsolved puzzle with the current algorithm</span></td></tr><tr><td class="number">148</td><td><span class="s">  "</span><span class="s">""</span></td></tr><tr><td class="number">149</td><td>  flags <span class="k3">=</span> <span class="k2">[</span><span class="k2">[</span>set<span class="k2">(</span><span class="k2">(</span><span class="n">1</span>,<span class="n">2</span>,<span class="n">3</span>,<span class="n">4</span>,<span class="n">5</span>,<span class="n">6</span>,<span class="n">7</span>,<span class="n">8</span>,<span class="n">9</span><span class="k2">)</span><span class="k2">)</span> <span class="k1">for</span> a in xrange<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">]</span> <span class="k1">for</span> b in xrange<span class="k2">(</span><span class="n">9</span><span class="k2">)</span><span class="k2">]</span></td></tr><tr><td class="number">150</td><td>&#160;</td></tr><tr><td class="number">151</td><td>  update_flags<span class="k2">(</span>puzzle, flags<span class="k2">)</span>        # initialize flags</td></tr><tr><td class="number">152</td><td>&#160;</td></tr><tr><td class="number">153</td><td>  filter1 <span class="k3">=</span> lambda x: len<span class="k2">(</span>x<span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">1</span></td></tr><tr><td class="number">154</td><td>  reduce1 <span class="k3">=</span> lambda x,y: filter<span class="k2">(</span>filter1, x<span class="k2">)</span> <span class="k3">+</span> filter<span class="k2">(</span>filter1, y<span class="k2">)</span></td></tr><tr><td class="number">155</td><td>  </td></tr><tr><td class="number">156</td><td>  <span class="k1">while</span> len<span class="k2">(</span>reduce<span class="k2">(</span>reduce1, flags<span class="k2">)</span><span class="k2">)</span><span class="k2">:</span>      # <span class="k1">while</span> flags with one possible value exist</td></tr><tr><td class="number">157</td><td>    <span class="k1">for</span> i in single_flag_iterator<span class="k2">(</span>flags<span class="k2">)</span><span class="k2">:</span>    # <span class="k1">for</span> every flag with one possible value</td></tr><tr><td class="number">158</td><td>      value <span class="k3">=</span> lookup<span class="k2">(</span>i, flags<span class="k2">)</span>.pop<span class="k2">(</span><span class="k2">)</span>    # retrieve <span class="k1">and</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_659.html" target="_blank">remove</a> that possible value from the set</td></tr><tr><td class="number">159</td><td>      lookup_set<span class="k2">(</span> i, puzzle, value <span class="k2">)</span>    # set the value in the puzzle</td></tr><tr><td class="number">160</td><td>      mark<span class="k2">(</span>i, flags, value<span class="k2">)</span>      # update flag markings</td></tr><tr><td class="number">161</td><td>    uniqueify_all<span class="k2">(</span>flags<span class="k2">)</span>        # update all flags <span class="k1">using</span> the uniqueness tests</td></tr><tr><td class="number">162</td><td>&#160;</td></tr><tr><td class="number">163</td><td>  filter2 <span class="k3">=</span> lambda x: x <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span></td></tr><tr><td class="number">164</td><td>  reduce2 <span class="k3">=</span> lambda x,y: filter<span class="k2">(</span>filter2, x<span class="k2">)</span> <span class="k3">+</span> filter<span class="k2">(</span>filter2, y<span class="k2">)</span></td></tr><tr><td class="number">165</td><td>  </td></tr><tr><td class="number">166</td><td>  <span class="k1">if</span> len<span class="k2">(</span>reduce<span class="k2">(</span>reduce2, puzzle<span class="k2">)</span><span class="k2">)</span><span class="k2">:</span>      # returns <span class="k1">false</span> <span class="k1">if</span> the puzzle isn<span class="s">'t compelte at this point</span></td></tr><tr><td class="number">167</td><td><span class="s">    return False</span></td></tr><tr><td class="number">168</td><td><span class="s">  </span></td></tr><tr><td class="number">169</td><td><span class="s">  return True</span></td></tr><tr><td class="number">170</td><td><span class="s"></span></td></tr><tr><td class="number">171</td><td><span class="s"></span></td></tr><tr><td class="number">172</td><td><span class="s"></span></td></tr><tr><td class="number">173</td><td><span class="s">if __name__ == '</span>__main__<span class="s">':</span></td></tr><tr><td class="number">174</td><td><span class="s">  puzzle = [[int(x) for x in raw_input()] for a in xrange(9)]    # Read puzzle from stdin</span></td></tr><tr><td class="number">175</td><td><span class="s">  if not solve(puzzle) and len(sys.argv) &gt; 1 and sys.argv[1] == '</span><span class="k3">-</span>v<span class="s">':  # if using the -v switch</span></td></tr><tr><td class="number">176</td><td><span class="s">    print "Cannot find solution to puzzle.  I got this far: "  # print warning message</span></td></tr><tr><td class="number">177</td><td><span class="s"></span></td></tr><tr><td class="number">178</td><td><span class="s">  for i in puzzle:</span></td></tr><tr><td class="number">179</td><td><span class="s">    print "%d%d%d%d%d%d%d%d%d" % tuple(i)        # output puzzle information</span></td></tr></tbody></table></div></div><p>

I&#39;m going to look into the more advanced solution methods and add them to the program.</p><p>EDIT:</p><p>Yes, if the constrant&#39;s are not local, it is quite difficult to solve the puzzle using bits (or sets, as I have in the above example) alone without adding some more &quot;interesting&quot; logic.</p><p>EDIT2:</p><p>As for the more simple puzzle, it looks like this above program takes only 3 passes to solve it (three rounds through the while loop in the solve function) <img src="http://www.allegro.cc/forums/smileys/shocked.gif" alt=":o" />.  And it only takes 3 passes before it realizes it cannot complete the harder puzzle as well. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Carrus85)</author>
		<pubDate>Sun, 23 Jul 2006 02:48:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Could someone translate that program into C so I can read it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (spunit262)</author>
		<pubDate>Sun, 23 Jul 2006 07:05:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, you could always just learn python.  It is great for just hacking up stuff.  I will admit though, some of the stuff I used in the above program is rather odd (yield, lambda&#39;s, [foo for bar in foobar()], reduce, filter)... <img src="http://www.allegro.cc/forums/smileys/cool.gif" alt="8-)" />.  I&#39;ll be the first to admit some of those functions don&#39;t apply cleanly in C though (you can do a lot of them in C++ using the STL). (No, I&#39;m not saying you can&#39;t do them in C, I&#39;m saying that you can&#39;t do them this easily in C)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Carrus85)</author>
		<pubDate>Sun, 23 Jul 2006 08:57:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
So, no, you cannot solve the puzzle simply by &quot;flagging&quot; possible solutions using the core rules.
</p></div></div><p>
That&#39;s what I meant by saying you need non-local constraints.<br />The good thing about the algorithm is that it is fast if it works.  I should really find the time to update my little solver...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sun, 23 Jul 2006 12:54:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The good thing about the algorithm is that it is fast if it works. I should really find the time to update my little solver...
</p></div></div><p>
What you get which can solve all Sudoku&#39;s is a good search with back-tracking. I think you could use an A* and measure the distance to the goal by the number of local constraints. So that it gets &quot;spot on&quot; if there are only local constraints all the way to the solved puzzle. In that case you will also get an optimal search (as it&#39;s one of the features of a correctly implemented A*).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kentl)</author>
		<pubDate>Sun, 23 Jul 2006 19:25:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
The good thing about the algorithm is that it is fast if it works. I should really find the time to update my little solver...
</p></div></div><p>

It&#39;s a SUDOKU. Even an unoptimized brute force solver needs less than one second for one of the harder puzzles (which your solver cannot even solve). I don&#39;t say that it is a sophisticated solution, but it works perfectly, and coding it takes about half an hour.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Simon Parzer)</author>
		<pubDate>Wed, 26 Jul 2006 23:51:35 +0000</pubDate>
	</item>
</rss>
