I've put the new one in place of the old one -- all visible at http://cpark.users.sonic.net/kakuro-python/. Besides the prettier HTML, which I got from Vegard Hanssen's site (see the above puzzle too), the new "k2.py" program has the following changes vs "k2-Mar_19_2255.py".
- Trivially, the old code had "HTML=True" near the top and the printout routine would output HTML if the variable was true. Yup...
- Almost as trivially (I don't think it made any difference), handle the process of setting a cell's determined value vs adjusting the content of its "possibles" list uniformly. There was one place we weren't doing that.
- Once we start dealing with permutations (the 2nd bullet in this earlier posting), find undecided cells that have only two possible values.
For each such cell, try out first one value, then the other, to see if it leads to a
contradiction. If it does lead to an impossibility, remove that value from
the list of "possibles" and thereby decide the value of that cell. For example, in
the aforementioned very hard puzzle #345943, doing the elementary steps brought us to this point:
A B C D E F G H 0 17 22 1 6 10 39 2 19 38 3 3 11 4 3 1 4 20 16 3 6 23 4 2 5 15 18 6 12 21 4 7 24 8 8 - 7D can be either 1 or 3 (see http://cpark.users.sonic.net/kakuro-python/veryhard.html for a complete list). But if
7D=1 then
- 8D=3 because of 6Ddown, and
- 8C=5 due to 8Bacross.
- Of the combinations allowed by 2Cdown, there's only one allowing 8C=5: (6,9,8,3,7,5), which dictates for example that 7C=7.
- This is a problem because 7Bacross doesn't have any permutations starting (7,1,...).
- Hence 7D cannot be 1.
- Therefore 7D=3, 8D=1, 8C=7, etc.
- 7D can be either 1 or 3 (see http://cpark.users.sonic.net/kakuro-python/veryhard.html for a complete list). But if
7D=1 then
No comments:
Post a Comment