<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sudoku creator/solver with PHP</title>
	<atom:link href="http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Fri, 10 Feb 2012 12:12:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: ??????</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-1024489</link>
		<dc:creator>??????</dc:creator>
		<pubDate>Thu, 22 Dec 2011 12:39:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-1024489</guid>
		<description>Thank you for this tutorial and i&#039;ll try to develope this code for a facebook application.</description>
		<content:encoded><![CDATA[<p>Thank you for this tutorial and i&#8217;ll try to develope this code for a facebook application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Emanuele Feronato</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-850458</link>
		<dc:creator>Emanuele Feronato</dc:creator>
		<pubDate>Sat, 11 Jun 2011 07:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-850458</guid>
		<description>Use as you want. If you are going to making money out of this, consider a small donation to triqui@libero.it</description>
		<content:encoded><![CDATA[<p>Use as you want. If you are going to making money out of this, consider a small donation to <a href="mailto:triqui@libero.it">triqui@libero.it</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Kessler</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-850408</link>
		<dc:creator>Max Kessler</dc:creator>
		<pubDate>Sat, 11 Jun 2011 05:28:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-850408</guid>
		<description>To clarify, I don&#039;t see a copyright notice in the *script*.</description>
		<content:encoded><![CDATA[<p>To clarify, I don&#8217;t see a copyright notice in the *script*.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Kessler</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-849362</link>
		<dc:creator>Max Kessler</dc:creator>
		<pubDate>Thu, 09 Jun 2011 18:06:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-849362</guid>
		<description>I don&#039;t see any copyright notice.  Did you release this to the public domain?  If not, then what are your terms with regard to derivative works?</description>
		<content:encoded><![CDATA[<p>I don&#8217;t see any copyright notice.  Did you release this to the public domain?  If not, then what are your terms with regard to derivative works?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-825189</link>
		<dc:creator>David</dc:creator>
		<pubDate>Wed, 04 May 2011 17:29:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-825189</guid>
		<description>Three bugs to fix.

1) The initial array is busted, it is too short.

FIX:

$sudoku = array(
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0
);


2) Initialize the variable $x before the loop within the function &quot;solve&quot;.

	$x = 0;
	
	while (!is_solved_sudoku($sudoku)) {
		$x++;

3) Check if the array has the key available.

function next_random($possible)
{
	$max = 9;
	
	for ($x = 0; $x &lt;= 80; $x++) {
		$keyExists = array_key_exists($x, $possible);
		
		if ($keyExists) {
			if ( (count($possible[$x])  0) ) {
				$max = count($possible[$x]);
				$min_choices = $x;
			}
		}
	}
	
	return $min_choices;
}</description>
		<content:encoded><![CDATA[<p>Three bugs to fix.</p>
<p>1) The initial array is busted, it is too short.</p>
<p>FIX:</p>
<p>$sudoku = array(<br />
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,<br />
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,<br />
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0<br />
);</p>
<p>2) Initialize the variable $x before the loop within the function &#8220;solve&#8221;.</p>
<p>	$x = 0;</p>
<p>	while (!is_solved_sudoku($sudoku)) {<br />
		$x++;</p>
<p>3) Check if the array has the key available.</p>
<p>function next_random($possible)<br />
{<br />
	$max = 9;</p>
<p>	for ($x = 0; $x &lt;= 80; $x++) {<br />
		$keyExists = array_key_exists($x, $possible);</p>
<p>		if ($keyExists) {<br />
			if ( (count($possible[$x])  0) ) {<br />
				$max = count($possible[$x]);<br />
				$min_choices = $x;<br />
			}<br />
		}<br />
	}</p>
<p>	return $min_choices;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-825186</link>
		<dc:creator>David</dc:creator>
		<pubDate>Wed, 04 May 2011 17:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-825186</guid>
		<description>Three bugs:

The initial array is busted, it is too short.

FIX:

$sudoku = array(
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0
);

In the function &quot;solve&quot;, initialize $x before the loop:

	$x = 0;
	
	while (!is_solved_sudoku($sudoku)) {
		$x++;

And the big one, check if a key for the array is valid, before trying to access it:


function next_random($possible)
{
	$max = 9;
	
	for ($x = 0; $x &lt;= 80; $x++) {
		$keyExists = array_key_exists($x, $possible);
		
		if ($keyExists) {
			if ( (count($possible[$x])  0) ) {
				$max = count($possible[$x]);
				$min_choices = $x;
			}
		}
	}
	
	return $min_choices;
} 

Very nice code, works extremely fast.</description>
		<content:encoded><![CDATA[<p>Three bugs:</p>
<p>The initial array is busted, it is too short.</p>
<p>FIX:</p>
<p>$sudoku = array(<br />
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,<br />
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,<br />
0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0,  0,0,0, 0,0,0, 0,0,0<br />
);</p>
<p>In the function &#8220;solve&#8221;, initialize $x before the loop:</p>
<p>	$x = 0;</p>
<p>	while (!is_solved_sudoku($sudoku)) {<br />
		$x++;</p>
<p>And the big one, check if a key for the array is valid, before trying to access it:</p>
<p>function next_random($possible)<br />
{<br />
	$max = 9;</p>
<p>	for ($x = 0; $x &lt;= 80; $x++) {<br />
		$keyExists = array_key_exists($x, $possible);</p>
<p>		if ($keyExists) {<br />
			if ( (count($possible[$x])  0) ) {<br />
				$max = count($possible[$x]);<br />
				$min_choices = $x;<br />
			}<br />
		}<br />
	}</p>
<p>	return $min_choices;<br />
} </p>
<p>Very nice code, works extremely fast.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rizta Husni Ananda</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-801812</link>
		<dc:creator>Rizta Husni Ananda</dc:creator>
		<pubDate>Fri, 08 Apr 2011 14:18:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-801812</guid>
		<description>Argh shoot...
Sorry my comment ruin your page. I didn&#039;t know that it would be displayed like that. You can just delete it if you mind.
Btw, on line 157 there&#039;s a bit warning. Some kind of undefined variable. Thank you.</description>
		<content:encoded><![CDATA[<p>Argh shoot&#8230;<br />
Sorry my comment ruin your page. I didn&#8217;t know that it would be displayed like that. You can just delete it if you mind.<br />
Btw, on line 157 there&#8217;s a bit warning. Some kind of undefined variable. Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rizta Husni Ananda</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-801805</link>
		<dc:creator>Rizta Husni Ananda</dc:creator>
		<pubDate>Fri, 08 Apr 2011 14:12:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-801805</guid>
		<description>For this particular problem (Platinum Blonde from Wikipedia):
$sudoku = array(0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,3,0,0,2,3,0,0,4,0,0,0,0,1,8,0,0,0,0,5,0,6,0,0,7,0,8,0,0,0,0,0,0,0,9,0,0,0,0,0,8,5,0,0,0,0,0,9,0,0,0,4,0,5,0,0,4,7,0,0,0,6,0,0,0);
And its solution:
839465712
146782953
752391486
391824675
564173829
287659341
628537194
913248567
475916238

My PHP script ran for 6.64 secs in my system. And yours for about 3 times longer. 
But still, your way of thinking is really interesting. Very much different than mine. I myself never use array push pop diff etc. 
Besides, I already spent over 500 lines of code for the basic elimination, trial &amp; error, backtracking function. But yours only took less than 200 LOC for everything.
Nice and neat. Good one dude!</description>
		<content:encoded><![CDATA[<p>For this particular problem (Platinum Blonde from Wikipedia):<br />
$sudoku = array(0,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,3,0,0,2,3,0,0,4,0,0,0,0,1,8,0,0,0,0,5,0,6,0,0,7,0,8,0,0,0,0,0,0,0,9,0,0,0,0,0,8,5,0,0,0,0,0,9,0,0,0,4,0,5,0,0,4,7,0,0,0,6,0,0,0);<br />
And its solution:<br />
839465712<br />
146782953<br />
752391486<br />
391824675<br />
564173829<br />
287659341<br />
628537194<br />
913248567<br />
475916238</p>
<p>My PHP script ran for 6.64 secs in my system. And yours for about 3 times longer.<br />
But still, your way of thinking is really interesting. Very much different than mine. I myself never use array push pop diff etc.<br />
Besides, I already spent over 500 lines of code for the basic elimination, trial &amp; error, backtracking function. But yours only took less than 200 LOC for everything.<br />
Nice and neat. Good one dude!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gg</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-762188</link>
		<dc:creator>gg</dc:creator>
		<pubDate>Mon, 21 Feb 2011 15:10:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-762188</guid>
		<description>chewdoku is better: try http://twasack.tripod.com/index.htm</description>
		<content:encoded><![CDATA[<p>chewdoku is better: try <a href="http://twasack.tripod.com/index.htm" rel="nofollow">http://twasack.tripod.com/index.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diallo</title>
		<link>http://www.emanueleferonato.com/2008/12/09/sudoku-creatorsolver-with-php/#comment-750238</link>
		<dc:creator>diallo</dc:creator>
		<pubDate>Wed, 09 Feb 2011 10:03:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=720#comment-750238</guid>
		<description>who can send me the sududu(php)</description>
		<content:encoded><![CDATA[<p>who can send me the sududu(php)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 6/11 queries in 0.027 seconds using disk: basic

Served from: www.emanueleferonato.com @ 2012-02-10 22:32:23 -->
