Mark Byer's site has some more Sudoku solvers here's a short one in Python that's only 178 bytes long: def r(a):i=a.find('0');~i or exit(a);[m in[(i-j)%9*(i/9^j/9)*(i/27^j/27|i%9/3^j%9/3)or a[j]for j in range(81)]or r(a[:i]+m+a[i+1:])for m in'%d'%5**18] from sys import*;r(argv[1]) On the site is also shown a longer Perl version at 185 bytes: use integer;sub R{for$i(grep!$A[$_],@x=0..80){%t=map{$_/27-$i/27|$_%9/3-$i%9/3&&amp;amp;$_ /9-$i/9&&($_-$i)%9?0:$A[$_]=>1}@x;R($A[$i]=$_)for grep!$t{$_},1..9;return$A[$i]=0} die@A}@A=split//,<>;R I think the Python version is slightly easier to understand, although they are both quite cryptic. I'm not sure why I find these programs fascinating. I think it reminds me that any program can be written in such a way that it's cryptic, even in Python. In addition, the code is small enough that you should be able to figure out how it works, and may learn something the process. Related is
Today I got a little sidetracked while working on my key-train (keyboard training) project. I thought I might spruce it up a little by using a seven segment display for the digits (say for the words per minutes), similar to what kTouch has. I found an open source font, but it appears to be difficult to just use a ttf font in GTK. So I figured, it's only 10 images, I'll just make them in svg. I vaguely remembered a heathenx inkscape podcast describing how to make an LCD display and decided to use that at my base. Unfortunately, they didn't provide any source files in the show-notes (as far as I could see) so I had to watch and redo the drawings myself! By naming each of the seven segments I could create the 10 digits simply by deleting a few elements in one template svg file . I can create the template as beautiful as I like and quickly create the 10 derived images with these programs . Unfortunately, both ImageMagick and GraphicsMagick don't handle
For fun I wasted some time creating diagrams using the dot language. It's pretty fast to get a diagram out, except that there are a lot of things you can't do, like make shadows or rounded and filled rectangles. With this dot code: digraph "User Clicks" { node [ shape="rectangle" style="filled" ] server [label="Server"] java [shape="ellipse" label="Java\nCode"] provider [label="Service\nProvider"] browser [label="Firefox"] browser->server[label=<① AJAX Sends Session ID>]; server->java[label=<② Confirms Session ID>]; java->provider[label=<③ Makes HTTPS call>]; provider->java[label=<④ Results>]; java->server[label=<⑤ Results>]; server->browser[label=<⑥ Results>]; } You can click on the image to see the SVG rendered in Firefox, if you use that. I wrote a little python program to call t
Comments