<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guy Rutenberg</title>
	<atom:link href="http://www.guyrutenberg.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Sat, 14 Jan 2012 11:30:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Gmail backup: getmail vs. OfflineIMAP</title>
		<link>http://www.guyrutenberg.com/2012/01/14/gmail-backup-getmail-vs-offlineimap/</link>
		<comments>http://www.guyrutenberg.com/2012/01/14/gmail-backup-getmail-vs-offlineimap/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 11:30:25 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[duplicity]]></category>
		<category><![CDATA[getmail]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[OfflineIMAP]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=956</guid>
		<description><![CDATA[I&#8217;m currently reviewing my backup plans and decided it&#8217;s a good occasion to finally start backing up my Gmail account. Firstly, I didn&#8217;t seriously consider Desktop clients as the main backup tool, as they are hard to automate. The two main options are: OfflineIMAP and getamil. Both are available from Ubuntu&#8217;s repositories, so installation is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently reviewing my backup plans and decided it&#8217;s a good occasion to finally start backing up my Gmail account. Firstly, I didn&#8217;t seriously consider Desktop clients as the main backup tool, as they are hard to automate. The two main options are: <a href="http://offlineimap.org/">OfflineIMAP</a> and <a href="http://pyropus.ca/software/getmail/">getamil</a>. Both are available from Ubuntu&#8217;s repositories, so installation is easy with both and both have good tutorials, <a href="http://www.mattcutts.com/blog/backup-gmail-in-linux-with-getmail/">Matt Cutts&#8217; getmail</a> and <a href="http://www.enigmacurry.com/2008/02/22/backing-up-my-online-brain/">EnigmaCurry&#8217;s OfflineIMAP</a>.</p>
<p>OfflineIMAP claims to be faster, but I haven&#8217;t really checked it (and I&#8217;m not sure how important that is giving that it runs in the background). From what I saw configuring them is mainly a task of cut-and-paste, but getmail requires to list every label you want to backup, which I consider is a major downside. As both are able to save the mails to maildir format, it should be easy to back it up using <a href="duplicity.nongnu.org">duplicity</a>.</p>
<p>Conclusion: This was a short comparison, mainly to guide me in choosing the right backup for me, you may have different opinions (which, of course, I would gladly hear). I finally chose OfflineIMAP, mainly due to the labels issue.</p>
<p>Note on desktop clients: It seems that every decent one can be configured to work with a local maildir, so you can use them to read the backups. As I prefer Gmail&#8217;s interface, I will only use desktop clients in case I&#8217;m offline, so read-only access from desktop client seems good enough for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2012/01/14/gmail-backup-getmail-vs-offlineimap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The annoying eBook vs. Paperback Pricing</title>
		<link>http://www.guyrutenberg.com/2011/12/30/the-annoying-ebook-vs-paperback-pricing/</link>
		<comments>http://www.guyrutenberg.com/2011/12/30/the-annoying-ebook-vs-paperback-pricing/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 10:17:24 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Kindle]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=949</guid>
		<description><![CDATA[I&#8217;m an avid Kindle user for more than a year. However once in a while, I come across something like this when I shopping for a new book: As you can see, Amazon sells Kindle edition for higher price than a paperback. This book of course isn&#8217;t the only example for this ridiculous pricing method, and if [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m an avid Kindle user for more than a year. However once in a while, I come across something like this when I shopping for a new book:</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2011/12/screenshot_ebook_price.png"><img class="aligncenter size-medium wp-image-950" title="screenshot_ebook_price" src="http://www.guyrutenberg.com/wp-content/uploads/2011/12/screenshot_ebook_price-300x228.png" alt="" width="300" height="228" /></a></p>
<p>As you can see, Amazon sells Kindle edition for higher price than a paperback. This book of course isn&#8217;t the only example for this ridiculous pricing method, and if one browses the Kindle store he will surely find more.</p>
<p>This really upsets me, as there is no honest reason to price an electronic edition higher than a real dead-tree paper edition. In both cases, the author and the publisher get their royalities and share of the profits. But the Kindle editions doesn&#8217;t have many related expenses, like storage, transportation (from the publisher to Amazon), and above all printing costs.</p>
<p>I don&#8217;t know who is to blame for this absurd thing, Amazon or the publisher (or even both). But the few things I know are that this bad for everyone, the customer because he pays more and Amazon/publisher as in the long run, this encourages piracy as the customer feels he&#8217;s being unfairly treated thus he will be more willing to play an unfair game as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/30/the-annoying-ebook-vs-paperback-pricing/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating a Deb for an Updated Version</title>
		<link>http://www.guyrutenberg.com/2011/12/17/creating-a-deb-for-an-updated-version/</link>
		<comments>http://www.guyrutenberg.com/2011/12/17/creating-a-deb-for-an-updated-version/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 16:16:04 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=928</guid>
		<description><![CDATA[Say you&#8217;ve an existing package like gitg and you want to use the new version of gitg or even apply your own patches. You could directly make install but you will probably regret it as soon as you&#8217;ll want to upgrade/uninstall, and you want to create a better package than the one created by checkinstall. [...]]]></description>
			<content:encoded><![CDATA[<p>Say you&#8217;ve an existing package like <code>gitg</code> and you want to use the new version of <code>gitg</code> or even apply your own patches. You could directly <code>make install</code> but you will probably regret it as soon as you&#8217;ll want to upgrade/uninstall, and you want to create a better package than the one created by <a href="">checkinstall</a>. Apperantly, creating a <code>deb</code> package for a new version of already packaged <code>deb</code> isn&#8217;t complicated.</p>
<h3>Getting Started</h3>
<p>Start by pulling the sources for the already available package. I&#8217;ll by using <code>gitg</code> as an example throughout this tutorial.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">apt-get source gitg</pre></div></div>

<p>This will create a folder according to the version of the package, something like <code>gitg-0.2.4</code>. Extract the new version besides it and <code>cd</code> into its directory. The next step is to copy the <code>debian/</code> directory from the old source package the code you&#8217;ve just extracted.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">cp -R ../gitg-0.2.4/debian/ .</pre></div></div>

<h3>Update <code>debian/</code> Files</h3>
<p>The next step is to update the files under the <code>debian/</code> sub-directory.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">DEBEMAIL=&quot;Guy Rutenberg &lt;myemail@domain.com&gt;&quot; debchange --nmu</pre></div></div>

<p>This will update the <code>debian/changelog</code> and set the new version. <code>--nmu</code> will create a new &#8220;non maintainer upload&#8221; version, meaning if the current version was <code>0.2.4-0ubuntu1</code>, it will change it to <code>0.2.4-0ubuntu1.1</code>. This will make sure that there won&#8217;t be any collision between your package and an official one. If you update to a new upstream version. It might be more suitable to use something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">debchange --newversion 0.2.5+20111211.git.20391c4</pre></div></div>

<p>If necessary, update the <code>Build-Depends</code> and <code>Depends</code> sections of <code>debian/control</code>.</p>
<h3>Building the Package</h3>
<p>If your building a package directly from version control and not part of an official release, you may need to run</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">./autogen</pre></div></div>

<p>at this point.</p>
<p>Now to the actual building:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">debuild -us -uc -i -I -B</pre></div></div>

<p><code>-us -uc</code> tells the script not to sign the <code>.dsc</code> and <code>.changes</code> files accordingly. <code>-i</code> and <code>-I</code> makes the script ignore common version control files. <code>-B</code> tells <code>debuild</code> to only create binary packages. You can also pass <code>-j</code> followed by the number of simultaneous jobs you wish to allow (e.g. <code>-j3</code>, like in <code>make</code>) which an significantly speed things up.</p>
<h3>Installing the Package</h3>
<p>The package will reside in the parent directory, for example:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">../gitg_0.2.5+20111211.git.20391c4_amd64.deb</pre></div></div>

<p>At this point you&#8217;re basically done. If you want to install the package you can use</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo debi</pre></div></div>

<p>while you&#8217;re still inside the build directory.</p>
<h3>References</h3>
<ul>
<li><a href="https://help.ubuntu.com/community/UpdatingADeb">UpdatingADeb</a></li>
<li>Man pages for <code>debuild</code>, <code>dpgk-genchanges</code>, <code>dpgk-buildpackage</code>.<br />
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/17/creating-a-deb-for-an-updated-version/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using gitg without installing</title>
		<link>http://www.guyrutenberg.com/2011/12/10/using-gitg-without-installing/</link>
		<comments>http://www.guyrutenberg.com/2011/12/10/using-gitg-without-installing/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 21:54:31 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[gitg]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=922</guid>
		<description><![CDATA[I&#8217;m working on adding spell checking support to gitg. If you intend to use gitg without installing it, a little hack is necessary. You&#8217;ll need to symlink the gitg directory (the one with the source files) as ui. ln -s gitg ui ./configure /pathto/below/gitg The reason is that gitg will look for Glade UI files [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on adding spell checking support to <a href="http://git.gnome.org/browse/gitg/">gitg</a>. If you intend to use gitg without installing it, a little hack is necessary. You&#8217;ll need to symlink the <code>gitg</code> directory (the one with the source files) as <code>ui</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ln -s gitg ui
./configure /pathto/below/gitg</pre></div></div>

<p>The reason is that <code>gitg</code> will look for Glade UI files under <code>$(datadir)/gitg/ui</code> and in gitg&#8217;s source the UI files are in the <code>gitg</code> directory and not in <code>ui</code>.</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2011/12/gitg-spellchecking.png"><img src="http://www.guyrutenberg.com/wp-content/uploads/2011/12/gitg-spellchecking.png" alt="" title="gitg-spellchecking" width="525" height="410" class="aligncenter size-full wp-image-923" /></a></p>
<p>You can see above a screenshot of <code>gitg</code> with spell checking enabled. Hopefully I&#8217;ll be done with the changes soon and they will be merged to upstream quickly.</p>
<p>Update: There are couple more things to do in order to get gsettings&#8217; schemas right.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mkdir glib-2.0
ln -s ../data glib-2.0/schemas
glib-compile-schemas data/
XDG_DATA_DIRS=&quot;.:/usr/share/&quot; ./gitg/gitg</pre></div></div>

<p>For the schemas thing see <a href="http://developer.gnome.org/gio/2.31/glib-compile-schemas.html">glib-compile-schemas</a>&#8216; man page.</p>
<p>Update 2011-12-17: Jesse (gitg&#8217;s maintainer) hasn&#8217;t responded to my email regarding the new feature, so I&#8217;ve open a bug (<a href="https://bugzilla.gnome.org/show_bug.cgi?id=666406">#666406</a>) for it. If you&#8217;re willing to try the changes yourself, you can pull them from <code>git://github.com/guyru/gitg.git spellchecker</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/10/using-gitg-without-installing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNOME_COMPILE_WARNINGS(maximum)  &#8211; Syntax Error in configure</title>
		<link>http://www.guyrutenberg.com/2011/12/10/gnome_compile_warningsmaximum-syntax-error-in-configure/</link>
		<comments>http://www.guyrutenberg.com/2011/12/10/gnome_compile_warningsmaximum-syntax-error-in-configure/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 17:23:48 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[GNOME]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=918</guid>
		<description><![CDATA[I&#8217;m still encountering migration issues from Gentoo to Ubuntu. Apperantly, Gentoo is much more user friendly than Ubuntu when it comes to compiling packages. In Gentoo you&#8217;ve got almost all the major dependencies you need. In Ubuntu, on the other hand, you need to hunt them down. It&#8217;s much easier with the main ones, as [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m still encountering migration issues from Gentoo to Ubuntu. Apperantly, Gentoo is much more user friendly than Ubuntu when it comes to compiling packages. In Gentoo you&#8217;ve got almost all the major dependencies you need. In Ubuntu, on the other hand, you need to hunt them down. It&#8217;s much easier with the main ones, as they are listed. But there are some small ones which are harder to track. I came across the following error while trying to compile <a href="http://git.gnome.org/browse/gitg/">gitg</a>, a GUI for Git, today:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">./configure: line 14447: syntax error near unexpected token `maximum'
./configure: line 14447: `GNOME_COMPILE_WARNINGS(maximum)'</pre></div></div>

<p>After not so short investigation I found out I was missing <code>gnome-common</code></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install gnome-common</pre></div></div>

<p>Why can&#8217;t be one distribution which is user-friendly like Ubuntu and in the same time developer-friendly like Gentoo?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/10/gnome_compile_warningsmaximum-syntax-error-in-configure/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Solving Sudoku using Python and Prolog</title>
		<link>http://www.guyrutenberg.com/2011/12/01/solving-sudoku-using-python-and-prolog/</link>
		<comments>http://www.guyrutenberg.com/2011/12/01/solving-sudoku-using-python-and-prolog/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:39:22 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Prolog]]></category>
		<category><![CDATA[Sudoku]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=911</guid>
		<description><![CDATA[Two weeks ago, I add came up with an interesting algorithm for solving Hidato which basically involves decomposing the board the grid (can be square, hexagonal or any other shape), into classes of pieces and then arranging them (maybe I&#8217;ll write a detailed post on it in the future). So while pondering whether it would [...]]]></description>
			<content:encoded><![CDATA[<p>Two weeks ago, I add came up with an interesting algorithm for solving <a href="http://en.wikipedia.org/wiki/Hidato">Hidato</a> which basically involves decomposing the board the grid (can be square, hexagonal or any other shape), into classes of pieces and then arranging them (maybe I&#8217;ll write a detailed post on it in the future). So while pondering whether it would be interesting enough to go forward and actually implementing the algorithm compared to the work it would require, I started thinking what will be the simplest way to solve such puzzles, as opposed to efficient.</p>
<p>At first I&#8217;ve looked at general purpose constraint solvers, and decided to tackle Sudoku instead as it&#8217;s a bit simple to define in terms of constraints. I considered several libraries but in the end I&#8217;ve settled on plainly using Prolog. I chose Prolog because as a logic programming language, constraints are its bread and butter. I although kind of liked it as I haven&#8217;t done anything in Prolog for quite a few years.</p>
<p>Describing Sudoku in terms of constraints is extremely simple. You need to state that every cell is in a given range and that all rows, columns and sub-grid contain different integers. As mangling with lists in prolog isn&#8217;t fun, I&#8217;ve wrote a python program that outputs all the prolog statements with hardcoded references to the variables which build-up the board. It&#8217;s ugly but dead simple. The script gets the dimensions of the sub-grid.<br />
<span id="more-911"></span></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
VAR_TEMPLATE = <span style="color: #483d8b;">&quot;G%02d%02d&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> puzzle_declaration<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>:
    lines = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">vars</span> = <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> j: VAR_TEMPLATE <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>i,j<span style="color: black;">&#41;</span>, <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        lines.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'['</span> + <span style="color: #483d8b;">', '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #008000;">vars</span><span style="color: black;">&#41;</span>+ <span style="color: #483d8b;">']'</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;puzzle(&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'  '</span> + <span style="color: #483d8b;">',<span style="color: #000099; font-weight: bold;">\n</span>  '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>lines<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;):-&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> constraints_range<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">vars</span> = <span style="color: black;">&#91;</span>VAR_TEMPLATE <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>i,j<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>Vars = [&quot;</span> + <span style="color: #483d8b;">', '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #008000;">vars</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;],&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>Vars ins 1..%d,&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> constraints_diff<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;"># rows</span>
    rows = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span>:
        row = <span style="color: black;">&#91;</span>VAR_TEMPLATE <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>i,j<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
        rows.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;all_different([&quot;</span> + <span style="color: #483d8b;">', '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>row<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;])&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    columns = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span>:
        column = <span style="color: black;">&#91;</span>VAR_TEMPLATE <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>i,j<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: #66cc66;">*</span>y<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
        columns.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;all_different([&quot;</span> + <span style="color: #483d8b;">', '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>column<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;])&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    rects = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> j <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>y<span style="color: black;">&#41;</span>:
            rect = <span style="color: black;">&#91;</span>VAR_TEMPLATE <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>k+y<span style="color: #66cc66;">*</span>i,l+x<span style="color: #66cc66;">*</span>j<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> k <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>y<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> l <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
            rects.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;all_different([&quot;</span> + <span style="color: #483d8b;">', '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>rect<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;])&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span> + <span style="color: #483d8b;">',<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>rows<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;,&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span> + <span style="color: #483d8b;">',<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>columns<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;,&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span> + <span style="color: #483d8b;">',<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>rects<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;.&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> generate_puzzle<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>:
    puzzle_declaration<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>
    constraints_range<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>
    constraints_diff<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__==<span style="color: #483d8b;">&quot;__main__&quot;</span>:
    x = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    y = <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    generate_puzzle<span style="color: black;">&#40;</span>x,y<span style="color: black;">&#41;</span></pre></div></div>

<p>For example running the script with <code>3 3</code> as arguments generates a regular 9&#215;9 Sudoku solver.</p>

<div class="wp_syntax"><div class="code"><pre class="prolog" style="font-family:monospace;"><span style="color: #339933;">:-</span> use_module<span style="color: #009900;">&#40;</span>library<span style="color: #009900;">&#40;</span>clpfd<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
puzzle<span style="color: #009900;">&#40;</span>
  <span style="color: #009900;">&#91;</span>G0000<span style="color: #339933;">,</span> G0001<span style="color: #339933;">,</span> G0002<span style="color: #339933;">,</span> G0003<span style="color: #339933;">,</span> G0004<span style="color: #339933;">,</span> G0005<span style="color: #339933;">,</span> G0006<span style="color: #339933;">,</span> G0007<span style="color: #339933;">,</span> G0008<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0100<span style="color: #339933;">,</span> G0101<span style="color: #339933;">,</span> G0102<span style="color: #339933;">,</span> G0103<span style="color: #339933;">,</span> G0104<span style="color: #339933;">,</span> G0105<span style="color: #339933;">,</span> G0106<span style="color: #339933;">,</span> G0107<span style="color: #339933;">,</span> G0108<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0200<span style="color: #339933;">,</span> G0201<span style="color: #339933;">,</span> G0202<span style="color: #339933;">,</span> G0203<span style="color: #339933;">,</span> G0204<span style="color: #339933;">,</span> G0205<span style="color: #339933;">,</span> G0206<span style="color: #339933;">,</span> G0207<span style="color: #339933;">,</span> G0208<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0300<span style="color: #339933;">,</span> G0301<span style="color: #339933;">,</span> G0302<span style="color: #339933;">,</span> G0303<span style="color: #339933;">,</span> G0304<span style="color: #339933;">,</span> G0305<span style="color: #339933;">,</span> G0306<span style="color: #339933;">,</span> G0307<span style="color: #339933;">,</span> G0308<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0400<span style="color: #339933;">,</span> G0401<span style="color: #339933;">,</span> G0402<span style="color: #339933;">,</span> G0403<span style="color: #339933;">,</span> G0404<span style="color: #339933;">,</span> G0405<span style="color: #339933;">,</span> G0406<span style="color: #339933;">,</span> G0407<span style="color: #339933;">,</span> G0408<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0500<span style="color: #339933;">,</span> G0501<span style="color: #339933;">,</span> G0502<span style="color: #339933;">,</span> G0503<span style="color: #339933;">,</span> G0504<span style="color: #339933;">,</span> G0505<span style="color: #339933;">,</span> G0506<span style="color: #339933;">,</span> G0507<span style="color: #339933;">,</span> G0508<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0600<span style="color: #339933;">,</span> G0601<span style="color: #339933;">,</span> G0602<span style="color: #339933;">,</span> G0603<span style="color: #339933;">,</span> G0604<span style="color: #339933;">,</span> G0605<span style="color: #339933;">,</span> G0606<span style="color: #339933;">,</span> G0607<span style="color: #339933;">,</span> G0608<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0700<span style="color: #339933;">,</span> G0701<span style="color: #339933;">,</span> G0702<span style="color: #339933;">,</span> G0703<span style="color: #339933;">,</span> G0704<span style="color: #339933;">,</span> G0705<span style="color: #339933;">,</span> G0706<span style="color: #339933;">,</span> G0707<span style="color: #339933;">,</span> G0708<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#91;</span>G0800<span style="color: #339933;">,</span> G0801<span style="color: #339933;">,</span> G0802<span style="color: #339933;">,</span> G0803<span style="color: #339933;">,</span> G0804<span style="color: #339933;">,</span> G0805<span style="color: #339933;">,</span> G0806<span style="color: #339933;">,</span> G0807<span style="color: #339933;">,</span> G0808<span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">:-</span>
	Vars <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>G0000<span style="color: #339933;">,</span> G0001<span style="color: #339933;">,</span> G0002<span style="color: #339933;">,</span> G0003<span style="color: #339933;">,</span> G0004<span style="color: #339933;">,</span> G0005<span style="color: #339933;">,</span> G0006<span style="color: #339933;">,</span> G0007<span style="color: #339933;">,</span> G0008<span style="color: #339933;">,</span> G0100<span style="color: #339933;">,</span> G0101<span style="color: #339933;">,</span> G0102<span style="color: #339933;">,</span> G0103<span style="color: #339933;">,</span> G0104<span style="color: #339933;">,</span> G0105<span style="color: #339933;">,</span> G0106<span style="color: #339933;">,</span> G0107<span style="color: #339933;">,</span> G0108<span style="color: #339933;">,</span> G0200<span style="color: #339933;">,</span> G0201<span style="color: #339933;">,</span> G0202<span style="color: #339933;">,</span> G0203<span style="color: #339933;">,</span> G0204<span style="color: #339933;">,</span> G0205<span style="color: #339933;">,</span> G0206<span style="color: #339933;">,</span> G0207<span style="color: #339933;">,</span> G0208<span style="color: #339933;">,</span> G0300<span style="color: #339933;">,</span> G0301<span style="color: #339933;">,</span> G0302<span style="color: #339933;">,</span> G0303<span style="color: #339933;">,</span> G0304<span style="color: #339933;">,</span> G0305<span style="color: #339933;">,</span> G0306<span style="color: #339933;">,</span> G0307<span style="color: #339933;">,</span> G0308<span style="color: #339933;">,</span> G0400<span style="color: #339933;">,</span> G0401<span style="color: #339933;">,</span> G0402<span style="color: #339933;">,</span> G0403<span style="color: #339933;">,</span> G0404<span style="color: #339933;">,</span> G0405<span style="color: #339933;">,</span> G0406<span style="color: #339933;">,</span> G0407<span style="color: #339933;">,</span> G0408<span style="color: #339933;">,</span> G0500<span style="color: #339933;">,</span> G0501<span style="color: #339933;">,</span> G0502<span style="color: #339933;">,</span> G0503<span style="color: #339933;">,</span> G0504<span style="color: #339933;">,</span> G0505<span style="color: #339933;">,</span> G0506<span style="color: #339933;">,</span> G0507<span style="color: #339933;">,</span> G0508<span style="color: #339933;">,</span> G0600<span style="color: #339933;">,</span> G0601<span style="color: #339933;">,</span> G0602<span style="color: #339933;">,</span> G0603<span style="color: #339933;">,</span> G0604<span style="color: #339933;">,</span> G0605<span style="color: #339933;">,</span> G0606<span style="color: #339933;">,</span> G0607<span style="color: #339933;">,</span> G0608<span style="color: #339933;">,</span> G0700<span style="color: #339933;">,</span> G0701<span style="color: #339933;">,</span> G0702<span style="color: #339933;">,</span> G0703<span style="color: #339933;">,</span> G0704<span style="color: #339933;">,</span> G0705<span style="color: #339933;">,</span> G0706<span style="color: #339933;">,</span> G0707<span style="color: #339933;">,</span> G0708<span style="color: #339933;">,</span> G0800<span style="color: #339933;">,</span> G0801<span style="color: #339933;">,</span> G0802<span style="color: #339933;">,</span> G0803<span style="color: #339933;">,</span> G0804<span style="color: #339933;">,</span> G0805<span style="color: #339933;">,</span> G0806<span style="color: #339933;">,</span> G0807<span style="color: #339933;">,</span> G0808<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	Vars ins <span style="color: #800080;">1</span><span style="color: #339933;">..</span><span style="color: #800080;">9</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0000<span style="color: #339933;">,</span> G0001<span style="color: #339933;">,</span> G0002<span style="color: #339933;">,</span> G0003<span style="color: #339933;">,</span> G0004<span style="color: #339933;">,</span> G0005<span style="color: #339933;">,</span> G0006<span style="color: #339933;">,</span> G0007<span style="color: #339933;">,</span> G0008<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0100<span style="color: #339933;">,</span> G0101<span style="color: #339933;">,</span> G0102<span style="color: #339933;">,</span> G0103<span style="color: #339933;">,</span> G0104<span style="color: #339933;">,</span> G0105<span style="color: #339933;">,</span> G0106<span style="color: #339933;">,</span> G0107<span style="color: #339933;">,</span> G0108<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0200<span style="color: #339933;">,</span> G0201<span style="color: #339933;">,</span> G0202<span style="color: #339933;">,</span> G0203<span style="color: #339933;">,</span> G0204<span style="color: #339933;">,</span> G0205<span style="color: #339933;">,</span> G0206<span style="color: #339933;">,</span> G0207<span style="color: #339933;">,</span> G0208<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0300<span style="color: #339933;">,</span> G0301<span style="color: #339933;">,</span> G0302<span style="color: #339933;">,</span> G0303<span style="color: #339933;">,</span> G0304<span style="color: #339933;">,</span> G0305<span style="color: #339933;">,</span> G0306<span style="color: #339933;">,</span> G0307<span style="color: #339933;">,</span> G0308<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0400<span style="color: #339933;">,</span> G0401<span style="color: #339933;">,</span> G0402<span style="color: #339933;">,</span> G0403<span style="color: #339933;">,</span> G0404<span style="color: #339933;">,</span> G0405<span style="color: #339933;">,</span> G0406<span style="color: #339933;">,</span> G0407<span style="color: #339933;">,</span> G0408<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0500<span style="color: #339933;">,</span> G0501<span style="color: #339933;">,</span> G0502<span style="color: #339933;">,</span> G0503<span style="color: #339933;">,</span> G0504<span style="color: #339933;">,</span> G0505<span style="color: #339933;">,</span> G0506<span style="color: #339933;">,</span> G0507<span style="color: #339933;">,</span> G0508<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0600<span style="color: #339933;">,</span> G0601<span style="color: #339933;">,</span> G0602<span style="color: #339933;">,</span> G0603<span style="color: #339933;">,</span> G0604<span style="color: #339933;">,</span> G0605<span style="color: #339933;">,</span> G0606<span style="color: #339933;">,</span> G0607<span style="color: #339933;">,</span> G0608<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0700<span style="color: #339933;">,</span> G0701<span style="color: #339933;">,</span> G0702<span style="color: #339933;">,</span> G0703<span style="color: #339933;">,</span> G0704<span style="color: #339933;">,</span> G0705<span style="color: #339933;">,</span> G0706<span style="color: #339933;">,</span> G0707<span style="color: #339933;">,</span> G0708<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0800<span style="color: #339933;">,</span> G0801<span style="color: #339933;">,</span> G0802<span style="color: #339933;">,</span> G0803<span style="color: #339933;">,</span> G0804<span style="color: #339933;">,</span> G0805<span style="color: #339933;">,</span> G0806<span style="color: #339933;">,</span> G0807<span style="color: #339933;">,</span> G0808<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0000<span style="color: #339933;">,</span> G0100<span style="color: #339933;">,</span> G0200<span style="color: #339933;">,</span> G0300<span style="color: #339933;">,</span> G0400<span style="color: #339933;">,</span> G0500<span style="color: #339933;">,</span> G0600<span style="color: #339933;">,</span> G0700<span style="color: #339933;">,</span> G0800<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0001<span style="color: #339933;">,</span> G0101<span style="color: #339933;">,</span> G0201<span style="color: #339933;">,</span> G0301<span style="color: #339933;">,</span> G0401<span style="color: #339933;">,</span> G0501<span style="color: #339933;">,</span> G0601<span style="color: #339933;">,</span> G0701<span style="color: #339933;">,</span> G0801<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0002<span style="color: #339933;">,</span> G0102<span style="color: #339933;">,</span> G0202<span style="color: #339933;">,</span> G0302<span style="color: #339933;">,</span> G0402<span style="color: #339933;">,</span> G0502<span style="color: #339933;">,</span> G0602<span style="color: #339933;">,</span> G0702<span style="color: #339933;">,</span> G0802<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0003<span style="color: #339933;">,</span> G0103<span style="color: #339933;">,</span> G0203<span style="color: #339933;">,</span> G0303<span style="color: #339933;">,</span> G0403<span style="color: #339933;">,</span> G0503<span style="color: #339933;">,</span> G0603<span style="color: #339933;">,</span> G0703<span style="color: #339933;">,</span> G0803<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0004<span style="color: #339933;">,</span> G0104<span style="color: #339933;">,</span> G0204<span style="color: #339933;">,</span> G0304<span style="color: #339933;">,</span> G0404<span style="color: #339933;">,</span> G0504<span style="color: #339933;">,</span> G0604<span style="color: #339933;">,</span> G0704<span style="color: #339933;">,</span> G0804<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0005<span style="color: #339933;">,</span> G0105<span style="color: #339933;">,</span> G0205<span style="color: #339933;">,</span> G0305<span style="color: #339933;">,</span> G0405<span style="color: #339933;">,</span> G0505<span style="color: #339933;">,</span> G0605<span style="color: #339933;">,</span> G0705<span style="color: #339933;">,</span> G0805<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0006<span style="color: #339933;">,</span> G0106<span style="color: #339933;">,</span> G0206<span style="color: #339933;">,</span> G0306<span style="color: #339933;">,</span> G0406<span style="color: #339933;">,</span> G0506<span style="color: #339933;">,</span> G0606<span style="color: #339933;">,</span> G0706<span style="color: #339933;">,</span> G0806<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0007<span style="color: #339933;">,</span> G0107<span style="color: #339933;">,</span> G0207<span style="color: #339933;">,</span> G0307<span style="color: #339933;">,</span> G0407<span style="color: #339933;">,</span> G0507<span style="color: #339933;">,</span> G0607<span style="color: #339933;">,</span> G0707<span style="color: #339933;">,</span> G0807<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0008<span style="color: #339933;">,</span> G0108<span style="color: #339933;">,</span> G0208<span style="color: #339933;">,</span> G0308<span style="color: #339933;">,</span> G0408<span style="color: #339933;">,</span> G0508<span style="color: #339933;">,</span> G0608<span style="color: #339933;">,</span> G0708<span style="color: #339933;">,</span> G0808<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0000<span style="color: #339933;">,</span> G0001<span style="color: #339933;">,</span> G0002<span style="color: #339933;">,</span> G0100<span style="color: #339933;">,</span> G0101<span style="color: #339933;">,</span> G0102<span style="color: #339933;">,</span> G0200<span style="color: #339933;">,</span> G0201<span style="color: #339933;">,</span> G0202<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0003<span style="color: #339933;">,</span> G0004<span style="color: #339933;">,</span> G0005<span style="color: #339933;">,</span> G0103<span style="color: #339933;">,</span> G0104<span style="color: #339933;">,</span> G0105<span style="color: #339933;">,</span> G0203<span style="color: #339933;">,</span> G0204<span style="color: #339933;">,</span> G0205<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0006<span style="color: #339933;">,</span> G0007<span style="color: #339933;">,</span> G0008<span style="color: #339933;">,</span> G0106<span style="color: #339933;">,</span> G0107<span style="color: #339933;">,</span> G0108<span style="color: #339933;">,</span> G0206<span style="color: #339933;">,</span> G0207<span style="color: #339933;">,</span> G0208<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0300<span style="color: #339933;">,</span> G0301<span style="color: #339933;">,</span> G0302<span style="color: #339933;">,</span> G0400<span style="color: #339933;">,</span> G0401<span style="color: #339933;">,</span> G0402<span style="color: #339933;">,</span> G0500<span style="color: #339933;">,</span> G0501<span style="color: #339933;">,</span> G0502<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0303<span style="color: #339933;">,</span> G0304<span style="color: #339933;">,</span> G0305<span style="color: #339933;">,</span> G0403<span style="color: #339933;">,</span> G0404<span style="color: #339933;">,</span> G0405<span style="color: #339933;">,</span> G0503<span style="color: #339933;">,</span> G0504<span style="color: #339933;">,</span> G0505<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0306<span style="color: #339933;">,</span> G0307<span style="color: #339933;">,</span> G0308<span style="color: #339933;">,</span> G0406<span style="color: #339933;">,</span> G0407<span style="color: #339933;">,</span> G0408<span style="color: #339933;">,</span> G0506<span style="color: #339933;">,</span> G0507<span style="color: #339933;">,</span> G0508<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0600<span style="color: #339933;">,</span> G0601<span style="color: #339933;">,</span> G0602<span style="color: #339933;">,</span> G0700<span style="color: #339933;">,</span> G0701<span style="color: #339933;">,</span> G0702<span style="color: #339933;">,</span> G0800<span style="color: #339933;">,</span> G0801<span style="color: #339933;">,</span> G0802<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0603<span style="color: #339933;">,</span> G0604<span style="color: #339933;">,</span> G0605<span style="color: #339933;">,</span> G0703<span style="color: #339933;">,</span> G0704<span style="color: #339933;">,</span> G0705<span style="color: #339933;">,</span> G0803<span style="color: #339933;">,</span> G0804<span style="color: #339933;">,</span> G0805<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	all_different<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>G0606<span style="color: #339933;">,</span> G0607<span style="color: #339933;">,</span> G0608<span style="color: #339933;">,</span> G0706<span style="color: #339933;">,</span> G0707<span style="color: #339933;">,</span> G0708<span style="color: #339933;">,</span> G0806<span style="color: #339933;">,</span> G0807<span style="color: #339933;">,</span> G0808<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></div></div>

<p>Again, not so pretty, but it&#8217;s python-generated hence simple as hell. Now solving is easily by passing integers instead of the variables. You can see below a prolog solution that demos solving a Sudoku. Another nice thing, is that if there isn&#8217;t a unique solution, it will be output say which cells have definite value, and output the constraints that hold for the rest of the cells.</p>
<p>I&#8217;ve tested it with both regular size Sudokus and mini-size (6&#215;6), and it seems to preform pretty fast.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">?- puzzle(
  [G0000, G0001,     1,     3, G0004, G0005, G0006, G0007,     8],
  [G0100, G0101,     7,     5,     6, G0105, G0106,     4, G0108],
  [G0200,     3, G0202, G0203,     7,     8,     6, G0207, G0208],
  [G0300, G0301,     4,     2, G0304, G0305, G0306, G0307,     6],
  [G0400,     9, G0402, G0403, G0404, G0405, G0406,     5, G0408],
  [    1, G0501, G0502, G0503, G0504,     5,     9, G0507, G0508],
  [G0600, G0601, G0602,     1,     2, G0605, G0606,     6, G0608],
  [G0700,     1, G0702, G0703,     3,     7,     5, G0707, G0708],
  [G0800, G0801, G0802, G0803, G0804,     9,     3, G0807, G0808]
).
&nbsp;
G0000 = 5,
G0001 = 6,
G0004 = 4,
G0005 = 2,
G0006 = 7,
G0007 = G0100, G0100 = 9,
G0101 = 8,
G0105 = 1,
G0106 = 2,
G0108 = 3,
G0200 = 4,
G0202 = 2,
G0203 = 9,
G0207 = 1,
G0208 = 5,
G0300 = 7,
G0301 = 5,
G0304 = 9,
G0305 = 3,
G0306 = 1,
G0307 = G0400, G0400 = 8,
G0402 = 3,
G0403 = 7,
G0404 = 1,
G0405 = 6,
G0406 = 4,
G0408 = G0501, G0501 = 2,
G0502 = 6,
G0503 = 4,
G0504 = 8,
G0507 = 3,
G0508 = 7,
G0600 = 3,
G0601 = 7,
G0602 = 5,
G0605 = 4,
G0606 = 8,
G0608 = 9,
G0700 = 6,
G0702 = 9,
G0703 = 8,
G0707 = 2,
G0708 = 4,
G0800 = 2,
G0801 = 4,
G0802 = 8,
G0803 = 6,
G0804 = 5,
G0807 = 7,
G0808 = 1.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/12/01/solving-sudoku-using-python-and-prolog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GCC Usage quirks</title>
		<link>http://www.guyrutenberg.com/2011/11/27/gcc-usage-quirks/</link>
		<comments>http://www.guyrutenberg.com/2011/11/27/gcc-usage-quirks/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 22:50:38 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[gcc]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=907</guid>
		<description><![CDATA[This is more of a note to myself, as it&#8217;s an error I keep bumping into. When compiling manually using gcc (or g++) you should pass all the libraries you&#8217;re compiling against at the end of the argument list. E.g.: g++ -Wall -lboost_thread my_file.cpp will result in error like: undefined reference to `boost::thread::join()' undefined reference [...]]]></description>
			<content:encoded><![CDATA[<p>This is more of a note to myself, as it&#8217;s an error I keep bumping into. When compiling manually using gcc (or g++) you should pass all the libraries you&#8217;re compiling against at the end of the argument list. E.g.:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">g++ -Wall -lboost_thread my_file.cpp</pre></div></div>

<p>will result in error like:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">undefined reference to `boost::thread::join()'
undefined reference to `boost::thread::~thread()'</pre></div></div>

<p>while</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">g++ -Wall vortex5_brute.cpp -lboost_thread</pre></div></div>

<p>works fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/11/27/gcc-usage-quirks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Number Exercises Separately in LyX</title>
		<link>http://www.guyrutenberg.com/2011/11/20/number-exercises-separately-in-lyx/</link>
		<comments>http://www.guyrutenberg.com/2011/11/20/number-exercises-separately-in-lyx/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 21:30:11 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[LyX]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=904</guid>
		<description><![CDATA[Say you&#8217;ve got a document with a bunch of exercises and few lemmas. You may want the exercises numbered separately from the numbering of the lemmas and theorem, unlike LyX&#8217;s default behavior. This can be achieved by redefining xca, the environment LyX uses for exercises. Add the following to your LaTeX preamble: \let\xca\@undefined \theoremstyle{plain} \newtheorem{xca}{\protect\exercisename} [...]]]></description>
			<content:encoded><![CDATA[<p>Say you&#8217;ve got a document with a bunch of exercises and few lemmas. You may want the exercises numbered separately from the numbering of the lemmas and theorem, unlike LyX&#8217;s default behavior. This can be achieved by redefining <code>xca</code>, the environment LyX uses for exercises. Add the following to your LaTeX preamble:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #E02020; ">\</span><span style="color: #800000;">let</span><span style="color: #800000; font-weight: normal;">\xca</span><span style="color: #E00000; font-weight: normal;">\@undefined</span>
<span style="color: #800000; font-weight: normal;">\theoremstyle</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">plain</span><span style="color: #E02020; ">}</span>
<span style="color: #800000; font-weight: normal;">\newtheorem</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">xca</span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\protect</span><span style="color: #800000; font-weight: normal;">\exercisename</span></span><span style="color: #E02020; ">}</span></pre></div></div>

<p>LyX will still display the incorrect numbering, but the output will be correct nonetheless. The first line, undefines the LyX&#8217;s definition of <code>xca</code>, then we set the style to match the old one and we redefine <code>xca</code>, this time without a reference to the theorems&#8217; counter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/11/20/number-exercises-separately-in-lyx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expectation Symbol in LaTeX</title>
		<link>http://www.guyrutenberg.com/2011/11/19/expectation-symbol-in-latex/</link>
		<comments>http://www.guyrutenberg.com/2011/11/19/expectation-symbol-in-latex/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 19:14:06 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[LyX]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=900</guid>
		<description><![CDATA[After looking for a builtin expectation symbol in LaTeX, and coming up with none, I&#8217;ve defined one. Just add: % Expectation symbol \DeclareMathOperator*{\E}{\mathbb{E}} to your LaTeX preamble and you&#8217;re done. You&#8217;ll also need to add \usepackage{amsmath} or in LyX to tick &#8220;Use AMS math package&#8221; under Document->Settings->Math Options. Using the starred version of \DeclareMathOperator makes [...]]]></description>
			<content:encoded><![CDATA[<p>After looking for a builtin expectation symbol in LaTeX, and coming up with none, I&#8217;ve defined one. Just add:</p>

<div class="wp_syntax"><div class="code"><pre class="latex" style="font-family:monospace;"><span style="color: #2C922C; font-style: italic;">% Expectation symbol</span>
<span style="color: #800000; font-weight: normal;">\DeclareMathOperator*</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\E</span></span><span style="color: #E02020; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\mathbb</span>{E</span><span style="color: #E02020; ">}}</span></pre></div></div>

<p>to your LaTeX preamble and you&#8217;re done. You&#8217;ll also need to add <code>\usepackage{amsmath}</code> or in LyX to tick &#8220;Use AMS math package&#8221; under Document->Settings->Math Options.</p>
<p>Using the starred version of <code>\DeclareMathOperator</code> makes sure subscripts goes beneath the symbol in display mode.</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2011/11/expectation-symbol.png"><img src="http://www.guyrutenberg.com/wp-content/uploads/2011/11/expectation-symbol.png" alt="" title="expectation-symbol" width="390" height="88" class="aligncenter size-full wp-image-901" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/11/19/expectation-symbol-in-latex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modified Variant Whitespace Template</title>
		<link>http://www.guyrutenberg.com/2011/11/17/modified-variant-whitespace-template/</link>
		<comments>http://www.guyrutenberg.com/2011/11/17/modified-variant-whitespace-template/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 19:16:47 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=889</guid>
		<description><![CDATA[Variant Whitespace is a nice minimalistic template by Andreas Viklund. Andreas chose to put the sidebar above the content, which I prefer not to do. Furthermore as the sidebar was a &#8220;float&#8221; that came before the content, it caused additional inconveniences. E.g. if you had an element with clear: both it would be pushed bellow [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://andreasviklund.com/templates/variant-whitespace/">Variant Whitespace</a> is a nice minimalistic template by <a href="http://andreasviklund.com/">Andreas Viklund</a>.</p>
<p><a href="http://www.guyrutenberg.com/wp-content/uploads/2011/11/variant-whitespace-700x549.png"><img src="http://www.guyrutenberg.com/wp-content/uploads/2011/11/variant-whitespace-700x549.png" alt="" title="variant-whitespace-700x549" width="700" height="549" class="aligncenter size-full wp-image-892" /></a></p>
<p>Andreas chose to put the sidebar above the content, which I prefer not to do. Furthermore as the sidebar was a &#8220;float&#8221; that came before the content, it caused additional inconveniences. E.g. if you had an element with <code>clear: both</code> it would be pushed bellow the sidebar. I&#8217;ve patched it a bit in order to fix those issues. You can find my modified version here: <a href="/wp-content/uploads/2011/11/variant-whitespace.tar.gz">variant-whitespace.tar.gz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2011/11/17/modified-variant-whitespace-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.531 seconds -->
<!-- Cached page served by WP-Cache -->

