Update 2011-02-09 Use version 14

Version 13 may be the fastest, but in transitioning from version 10→11 we lost the ability to solve the veryhard puzzle. Revisions 11-13 don't solve it. The change is quite short:
@@ -87,8 +87,7 @@
             passno += 1
 
             for acell in [x for x in reduce(lambda a,b:a+b, the_puzzle) 
-                          if x.type == 0 and len(x.possibles) == 2]:
-                # For now try it only on cells having exactly 2 possibles
+                          if x.type == 0]:
                 for aval in acell.possibles:
                     achange = cut_contradictory_possibles(acell, aval)
                     more_to_do += achange 

Update 2010-03-28: This version is 60-90x as fast

I wouldn't care about the speed except that the previous version took over 15 minutes to solve the puzzle of http://www.bestkakuro.com/killer2.gif (click the figure at right to see a larger image). Version 7 is what I had last week. Version 11 is probably the fastest. Here are some times for comparison; I ran each version twice using time(1) and entered here the shorter of the two "user" times:
version# Athlon64 3000+, 1GHz
Bogomips 2009.75
Python 2.6.2
Linux 2.6.28 (Ubuntu 9.04)
Xeon 5150, 2.6GHz
bogomips 5333.61
Python 2.4.3
Linux 2.6.18 (RHEL 5.4)
Powerbook G4, 1.67GHz
Python 2.3.5
Mac OS X 10.4 (Tiger)
7 (from last week) 15m41.179s 5m54.746s 54m36.416s
8 (k2-8.py) 14m45.403s 4m54.429s 45m45.055s
9 (k2-9.py) 14m41.455s 4m47.196s 45m41.441s
10 (k2-10.py) 1m55.443s 0m53.560s 5m58.529s
11 (k2-11.py) 0m8.561s 0m5.346s 0m27.454s
12 (k2-12.py) 0m10.241s 0m7.735s 0m32.570s
13 (k2-13.py) 2010-03-29 0m7.040s 0m4.628s 0m22.976s
output
14 (k2-14.py) 2011-02-09 ? ? 26sec
What do the versions do?

Update 2010-03-21: Solves Vegard Hanssen's very hard puzzles

...and has prettier output. The old k2.py is here at k2-Mar_19_2255.py, but it couldn't solve, for example, puzzle #345943 (marked "very hard", and it is).

The new k2.py can; it has prettier HTML, too. See download section for sources.
An example of the prettier html is at veryhard.html, which was created like this:

./k2.py < veryhard-messeske.no-395943 > veryhard.html
Here's "very hard" puzzle #345943 solved:

  A B C D E F G H
0          
 
17
 
22
 
1      
 
6
10
39
8 2  
2    
19
38
1 4 9 5
 
3
3  
11
 
3 2 6
4
 
3 1
4  
20
16
9 3 8
6
23
4 2
5
15
 
9 6
18
 
9 8 1  
6
12
 
7 5
21
4
5 9 7  
7  
24
 
8 3 7 6    
8  
8
 
7 1        

Update 2010-03-19: HTML output

... as seen at http://collinpark.blogspot.com/2010/03/last-kakuro-posting-for-while-i-promise.html !
New program: k2.py; see download section for sources.
Run it as:
$ ./k2.py < sample-march7.txt > march7.html
Output looks like this:
    A     B     C     D     E     F     G     H     I     J     K     L     M     N  
0    
 
⇓29
 
⇓16
 
⇓17
 
 
⇓21
 
⇓11
 
⇓8
   
 
⇓6
 
⇓34
 
1  
24⇒
⇓15
7 9 8
7⇒
 
4 2 1  
8⇒
⇓6
1 7
 
⇓23
2
29⇒
 
8 5 7 9
24⇒
⇓12
8 9 7
14⇒
⇓10
2 5 1 6
3
16⇒
 
7 9
 
⇓8
16⇒
⇓23
7 9  
3⇒
 
2 1
13⇒
 
4 9
4  
26⇒
 
8 7 6 5    
4⇒
⇓15
1 3
14⇒
⇓16
6 8
5    
10⇒
 
1 9
 
⇓16
 
9⇒
⇓10
2 7
14⇒
 
9 5
 
⇓10
6  
 
⇓10
 
⇓34
17⇒
 
8 9
5⇒
⇓13
1 4
 
⇓9
11⇒
 
7 3 1
7
4⇒
 
1 3
 
⇓16
35⇒
 
7 5 6 9 8
 
⇓24
17⇒
 
8 9
8
17⇒
 
9 1 7  
5⇒
⇓24
2 3
10⇒
 
1 9
 
⇓9
   
9  
14⇒
⇓6
5 9
13⇒
⇓11
7 6    
14⇒
⇓10
8 6
 
⇓13
 
10
6⇒
 
2 4
13⇒
 
4 9    
19⇒
⇓11
8 7 3 1
 
⇓10
11
8⇒
 
1 7
14⇒
⇓7
6 8
 
⇓12
3⇒
⇓7
1 2
 
⇓10
3⇒
⇓6
2 1
12
12⇒
 
3 6 2 1
6⇒
 
3 1 2
29⇒
 
8 5 7 9
13  
13⇒
 
8 5  
23⇒
 
9 6 8
6⇒
 
2 1 3  

Files to accompany

Download

The program text is Copyright © 2010 Collin Park; see the source for details. If your browser tries to execute the programs when you click on the link, you can try using right-click (or ctrl-click on Mac OS) and "save as". You may need to run Python explicitly if /usr/bin/python doesn't exist on your computer. It's been run under Python 2.3.4 and Python 2.6.2.

What you need to download: Here's the text: Here are a few sample puzzles: Here's an example of how to run the program.
$ ./k1.py < Hard_Kakuro_for_19.March.2010 
k1.py: solve a kakuro puzzle from stdin
    Copyright (C) 2010 Collin Park

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    See <http://www.gnu.org/licenses/> for full license text. 
The above is just so everyone knows that the program is free for anyone to use under the GPL. There's probably a more professional way to do this, like "No warranty; type 'show c' for copyright" or something like that, but this isn't a professional project; I'm just playing.
      A     B     C     D     E     F     G  
   +-----+-----+-----+-----+-----+-----+-----+
  0|XXXXX|XXXXX|11\  |25\  |XXXXX|XXXXX|XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  1|XXXXX|27\ 6| ___ | ___ |20\  |12\  |13\  |
   +-----+-----+-----+-----+-----+-----+-----+
  2|  \39| ___ | ___ | ___ | ___ | ___ | ___ |
   +-----+-----+-----+-----+-----+-----+-----+
  3|XXXXX| ___ | 7\30| ___ | ___ | ___ | ___ |
   +-----+-----+-----+-----+-----+-----+-----+
  4|  \11| ___ | ___ | ___ | ___ | 6\  | ___ |
   +-----+-----+-----+-----+-----+-----+-----+
  5|  \21| ___ | ___ | ___ | ___ |  5  | ___ |
   +-----+-----+-----+-----+-----+-----+-----+
  6|XXXXX|XXXXX|XXXXX|  \ 4|  3  |  1  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
The solver stops after executing steps #1-#6 as described here. As you can see in this rather hard puzzle, those steps filled in three whole cells, leaving 23 (if I counted correctly) still open. Below is some information I used in trying to decide what to do next.

Lines starting with "%%%" give the list of possible values for the named cell; lines starting with ">>>" give the list of possible combinations for the named total.

%%% 1C [2, 4, 5]
%%% 1D [1, 2, 4, 5]
%%% 2B [5, 6, 7, 8, 9]
%%% 2C [4, 5, 6, 7, 9]
%%% 2D [4, 5, 6, 7, 8, 9]
%%% 2E [4, 5, 6, 7, 8, 9]
%%% 2F [4, 5, 7, 8, 9]
%%% 2G [4, 6, 7]
%%% 3B [3, 5, 6, 7, 8, 9]
%%% 3D [6, 7, 8, 9]
%%% 3E [6, 7, 8, 9]
%%% 3F [7, 8, 9]
%%% 3G [6, 7]
%%% 4B [3, 5]
%%% 4C [1, 2, 3, 5]
%%% 4D [1, 2, 3, 5]
%%% 4E [1, 2, 5]
%%% 4G [1, 2, 3, 4, 6, 7]
%%% 5B [3, 6]
%%% 5C [1, 2, 3, 4, 6]
%%% 5D [1, 2, 3, 4, 6]
%%% 5E [1, 2, 4, 6]
%%% 5G [1, 2, 3, 4, 6]
>>> 0C down [(5, 6), (4, 7), (2, 9)]
>>> 0D down [(3, 4, 5, 6, 7), (2, 4, 5, 6, 8), (2, 3, 5, 7, 8), (1, 4, 5, 7, 8), (1, 3, 6, 7, 8), (2, 3, 5, 6, 9), (1, 4, 5, 6, 9), (2, 3, 4, 7, 9), (1, 3, 5, 7, 9), (1, 2, 6, 7, 9), (1, 3, 4, 8, 9), (1, 2, 5, 8, 9)]
>>> 1B across [(2, 4), (1, 5)]
>>> 1B down [(5, 6, 7, 9), (3, 7, 8, 9)]
>>> 1E down [(2, 3, 4, 5, 6), (1, 3, 4, 5, 7), (1, 2, 3, 6, 8), (1, 2, 3, 5, 9)]
>>> 1F down [(5, 7), (4, 8), (3, 9)]
>>> 1G down [(1, 2, 4, 6), (1, 2, 3, 7)]
>>> 2A across [(4, 5, 6, 7, 8, 9)]
>>> 3C across [(6, 7, 8, 9)]
>>> 3C down [(3, 4), (2, 5), (1, 6)]
>>> 4A across [(1, 2, 3, 5)]
>>> 5A across [(1, 2, 3, 4, 5, 6)]
After printing the intermediate results above, the program proceeds to finish the job. So far it's been successful.
      A     B     C     D     E     F     G  
   +-----+-----+-----+-----+-----+-----+-----+
  0|XXXXX|XXXXX|11\  |25\  |XXXXX|XXXXX|XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  1|XXXXX|27\ 6|  2  |  4  |20\  |12\  |13\  |
   +-----+-----+-----+-----+-----+-----+-----+
  2|  \39|  7  |  9  |  8  |  6  |  5  |  4  |
   +-----+-----+-----+-----+-----+-----+-----+
  3|XXXXX|  9  | 7\30|  9  |  8  |  7  |  6  |
   +-----+-----+-----+-----+-----+-----+-----+
  4|  \11|  5  |  3  |  1  |  2  | 6\  |  1  |
   +-----+-----+-----+-----+-----+-----+-----+
  5|  \21|  6  |  4  |  3  |  1  |  5  |  2  |
   +-----+-----+-----+-----+-----+-----+-----+
  6|XXXXX|XXXXX|XXXXX|  \ 4|  3  |  1  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
$ 
Here's what happens when you feed it an "easy" puzzle:
$ ./k1.py < easy.19mar2010 
k1.py: solve a kakuro puzzle from stdin
    Copyright (C) 2010 Collin Park

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    See  for full license text. 
      A     B     C     D     E     F     G  
   +-----+-----+-----+-----+-----+-----+-----+
  0|XXXXX|XXXXX|XXXXX|XXXXX|10\  |17\  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  1|XXXXX|XXXXX| 3\12|  1  |  2  |  9  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  2|  \ 3|  2  |  1  |10\ 9|  1  |  8  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  3|XXXXX|  \ 6|  2  |  1  |  3  |17\  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  4|XXXXX|XXXXX| 3\15|  2  |  4  |  9  |XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
  5|XXXXX|  \ 5|  2  |  3  |  \ 9|  8  |  1  |
   +-----+-----+-----+-----+-----+-----+-----+
  6|XXXXX|  \ 7|  1  |  4  |  2  |XXXXX|XXXXX|
   +-----+-----+-----+-----+-----+-----+-----+
$ 
Just running steps #1-6 solved that one.