Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Hard puzzle for DXL.

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Puzzles
View previous topic :: View next topic  
Author Message
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Sun Aug 14, 2005 7:22 pm    Post subject: Hard puzzle for DXL. Reply with quote

I've written two solvers, a fast one based on Knuth's 'dancing links' and a slow one for estimating puzzle difficulty for humans. I'm interested in finding ways to use the metrics I can get from DXL (dancing links) to estimate puzzle difficulty.

The dancing links method solves pretty much any solvable sudoku in just a few milliseconds. It does find some puzzles harder than others in the sense that simple puzzles reduce down to a single choices (dxl columns with a length of 1) whereas more difficult puzzles tend to generate more instances where the smallest dxl column is > 1.

Using this metric, the hardest puzzle posted on this board for DXL has been rubylip's, which generates 51 such dxl columns with a length > 1 - meaning some form of 'what-if' would be required 51 times. It's possible this can be reduced by transposition.

Code:

.....3.6........1..975...8.....9.2....8.7.4....3.6.....1...289..4........5.1.....


This morning, I generated about 12,000 puzzles. Only one came out harder than rubylips' puzzle. This next one, which I'm calling "jbum-69" since it requires 69 multiple choices using the dancing links algorithm.

Code:

.2..5..8.9....2..66..9.7...27.........1.4.8.........17...6.4..37..2....8.3..1..7.


I can reduce the difficulty a bit via transposition. I will probably modify
the way I check difficulty by trying all possible tranpositions and using the lowest DXL number...

EDIT: Here is the puzzle in Kudosu's recommended format. I personally prefer the single-line string for convienence.

Code:

. 2 . | . 5 . | . 8 .
9 . . | . . 2 | . . 6
6 . . | 9 . 7 | . . .
---------------------
2 7 . | . . . | . . .
. . 1 | . 4 . | 8 . .
. . . | . . . | . 1 7
---------------------
. . . | 6 . 4 | . . 3
7 . . | 2 . . | . . 8
. 3 . | . 1 . | . 7 .

_________________
http://www.krazydad.com/
Back to top
View user's profile Send private message Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Mon Aug 15, 2005 5:51 am    Post subject: Reply with quote

yes, these two are also hard for me, although there are harder
ones in my list for my solver.

the first one required 78 choices of DLX-columns with more than 1 entry
and 1102 placements in total

the second 62 and 791.

It just depends how the sudoku is oriented and how your matrix
is ordered.
You can do random equivalence transformation of the sudoku
or random permuting of the rows and columns in the
exact-cover matrix and you may see completely different
results in some cases.


Guenter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Mon Aug 15, 2005 6:25 am    Post subject: Reply with quote

Yes, I agree. At some point I'm going to iterate thru the transliterations so I can record the lowest difficulty...
_________________
http://www.krazydad.com/
Back to top
View user's profile Send private message Visit poster's website
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Mon Aug 15, 2005 9:33 pm    Post subject: More hard puzzles Reply with quote

I've been working on getting my puzzle generator to search for hard puzzles (identifying puzzles that generate a lot of branching in the depth
first search).

I generated these last night, they are sorted by estimated difficulty with the harder ones at the top.

Note that my generator always generates puzzles with 1-9 in order in the top row. This helps speed up puzzle generation. If preparing these puzzles for humans (e.g. my wife), I randomly transliterate the numbers with a perl script.

Code:

.2..5.78....9...6...8..2...31...76...4.....7...73...21...8..9...9...5....84.7..1. 
........9.4.7.15.3..73....6..2.6.3...3.....5...5.2.4..3....89..2.49.5.3.9........ 
..3..67.9....73.26.7.........1..9.787.......184.6..9.........1.49.83....3.75..8.. 
...456....4.....2...8.1.5..81....9.3....7....6.2....18..1.6.3...3.....9....739... 
1...5..8...78....14..3....684.......7.2...1.3.......542....5..89....14...1..9...5 
..34..7....97..42..7......3..6...39.5..9.1..4.84...5..3......6..45..92....1..79.. 
.234....9..........85..9.4323....6..9..6.2..7..4....5134.5..97..........5....732. 
1.34......8..2....4...7.3..8......47...7.5...76......1..2.1...8....9..6......81.5 
.2....7..6..1..235.5......4...36...8....4....9...71...3......4.498..3..6..6....2. 
.........6...924...4...3.12.1....3.5....6....9.4....7.79.3...2...167...8......... 
........9...1.7.53.5.93.6......758..9.......6..634......1.94.6.74.5.3...8........ 
1.3.5..8.4.....1....5.7.46.3....8....5.....7....9....1.32.8.5....1.....7.9..2.8.6 
......7.......3..14.9.2.56...2.9..57..45.29..95..1.6...95.6.8.47..8.......1...... 
12...67....48......68..2....3.9...64..9...5..64...1.9....1..92......86....26...57 
..3.5...9..5......6.4.823.....3..9..45.....36..9..1.....683.1.4......8..8...6.5.. 
...4.....49.2..6..7...13..2...83...4..2...8..9...27...3..58...7..7..9.18.....1... 
...4.6....4......6..92.35....19...48..5...2..28...41....41.29..9......3....8.9... 
1...5.7.9..81..3.........4135...98....4...1....78...9393.........5..32..4.2.8...7 
....5...9.6.....3.5..3.941.3..6.....6..8.1..3.....5..7.315.7..4.5.....2.4...8.... 
.2.4..7..9....7..15..98..2.81...........2...........34.9..72..86..1....5..1..3.7. 
.....67.9..83..4...5........81.43...7..1.5..3...72.14........9...7..16..6.25..... 
.2..5...9..78..56.6.57.......43...7.3...2...4.6...43.......86.7.46..31..9...6..4. 
....5..89..71......65..71..5.....4...36...51...4.....8..87..94......13..34..2.... 
.2.4..7.98...2..4.....7.2..2..6..1...3.....9...1..9..7..9.6.....1..3...45.2..4.7. 
.23..67..4.....36........4287.2....3....3....6....5.7491........46.....8..79..43. 
12...6.....51...3..8..39..1..1..4..8.4.....7.8..3..1..2..64..5..5...14.....9...13 
.2..5..8......3.1..8.2.93..9.2.4..7...........5..2.4.8..16.4.3..6.5......3..7..4. 
1..4....9....2.4.....7..1.3.35..19.............98..37.3.2..4.....8.7....6....2..7 
123.......5...81....9...6.....6.9..4.6..3..7.3..2.4.....8...5....13...9.......312 
.23.....958...7.3.........1.4.7..5.....1.3.....6..5.9.2.........9.6...787.....24. 
.2......94.6...3...5.8....676.13...2...2.9...3...68.716....2.3...1...2.82......6. 
..3...7.9...3..4..48.17..5.5..2..8..9.......6..2..4..5.1..45.97..5..3...7.4...5.. 

_________________
http://www.krazydad.com/
Back to top
View user's profile Send private message Visit poster's website
Merri

Joined: 02 Aug 2005
Posts: 44
:

Items
PostPosted: Mon Aug 15, 2005 9:43 pm    Post subject: Reply with quote

To compare against pure computer processing speed with some brute force approach, here are some results:

Code:
Total time for 32 files: 8,625119 milliseconds
0,852343 ms:   hard_dxl\0008_batch_hard_dxl.msk
0,633321 ms:   hard_dxl\0012_batch_hard_dxl.msk
0,540571 ms:   hard_dxl\0010_batch_hard_dxl.msk
0,540013 ms:   hard_dxl\0026_batch_hard_dxl.msk
0,502019 ms:   hard_dxl\0002_batch_hard_dxl.msk
0,379098 ms:   hard_dxl\0017_batch_hard_dxl.msk
0,364292 ms:   hard_dxl\0007_batch_hard_dxl.msk
0,346413 ms:   hard_dxl\0021_batch_hard_dxl.msk
0,323505 ms:   hard_dxl\0031_batch_hard_dxl.msk
0,294730 ms:   hard_dxl\0018_batch_hard_dxl.msk
0,279086 ms:   hard_dxl\0025_batch_hard_dxl.msk
0,269308 ms:   hard_dxl\0001_batch_hard_dxl.msk
0,247797 ms:   hard_dxl\0013_batch_hard_dxl.msk
0,234387 ms:   hard_dxl\0019_batch_hard_dxl.msk
0,223213 ms:   hard_dxl\0005_batch_hard_dxl.msk
0,214832 ms:   hard_dxl\0024_batch_hard_dxl.msk
0,212597 ms:   hard_dxl\0016_batch_hard_dxl.msk
0,207289 ms:   hard_dxl\0028_batch_hard_dxl.msk
0,205054 ms:   hard_dxl\0030_batch_hard_dxl.msk
0,198070 ms:   hard_dxl\0023_batch_hard_dxl.msk
0,178235 ms:   hard_dxl\0022_batch_hard_dxl.msk
0,168178 ms:   hard_dxl\0006_batch_hard_dxl.msk
0,165105 ms:   hard_dxl\0011_batch_hard_dxl.msk
0,152813 ms:   hard_dxl\0003_batch_hard_dxl.msk
0,148902 ms:   hard_dxl\0004_batch_hard_dxl.msk
0,132419 ms:   hard_dxl\0014_batch_hard_dxl.msk
0,127949 ms:   hard_dxl\0020_batch_hard_dxl.msk
0,127670 ms:   hard_dxl\0015_batch_hard_dxl.msk
0,111746 ms:   hard_dxl\0029_batch_hard_dxl.msk
0,109511 ms:   hard_dxl\0027_batch_hard_dxl.msk
0,095543 ms:   hard_dxl\0032_batch_hard_dxl.msk
0,039111 ms:   hard_dxl\0009_batch_hard_dxl.msk


They are relatively easy for my simple logic backtracker (you find the description elsewhere). Hardest sudokus for the solver take about 6 ms. Easiest ones take 0,02 ms.
Back to top
View user's profile Send private message
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Mon Aug 15, 2005 9:48 pm    Post subject: thanks merri Reply with quote

Cool - thanks a lot. It looks like I sorted them roughly accurately.

If you can point me to a thread that contains some of those 6 ms monsters, I'd like to check 'em out.

Thanks!
_________________
http://www.krazydad.com/
Back to top
View user's profile Send private message Visit poster's website
Merri

Joined: 02 Aug 2005
Posts: 44
:

Items
PostPosted: Mon Aug 15, 2005 10:00 pm    Post subject: Reply with quote

Actually not, if you check the file names they're pretty much "random" and not in any special order at all when compared to yours. The 6 ms "monsters" are probably easier for a non-backtracker approach. However, here are some which take more than 4 ms:

.......473..5............1.7.9...6......1..........2.....2..7.5.41..8....3.......
....4.61.2.53...........9..4......82.6..1.............7..5.2......8..1...........
....61....9.....3..........6.1...7.....75..8.4...........2..4.9.5.3...........1..
....7.51.2.63...........8..4......92.5..1.............6..4.2......6..1...........
..5.4....7......2......1......5..3.....6...7..1.......8..2.3.......5.1.4......6..
2..4..1...6..5.............3..8.......42............76....71....5..6......8...3..
2..4..1...6..5.............3..9.......82............76....71....5..6......9...3..
37.4........7...5.........1.4....2......8...6....1.......2..7..6......4.1.8......

These are in no particular order, just the TOP 8 of the latest benchmark run. My times vary, it would be better if I had a difficulty rating instead of a timing code, but can't be helped: taking part in a contest with the code. You can find a compiled version here.

You can find those and 7603 puzzles more at http://www.csse.uwa.edu.au/~gordon/sudoku17 - these are all 17 clues puzzles.
Back to top
View user's profile Send private message
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Mon Aug 15, 2005 10:04 pm    Post subject: Thanks Reply with quote

Thanks again. Smile

Clearly our solvers are sensitive to different things. My DXL solver is also a backtracking (depth first search) solver, but it solves this set about
twice as fast as the ones I posted previously.

My intuition is that the dancing links algorithm views the puzzles in a very
odd way... Smile

The hardest ones in your list for me (#2 and #4) generate 9 and 8 backtracks, respectively, while all the ones in my list were generating 30+
backtracks in DXL. Some of the puzzles in your list generated 1 or 0 backtracks.

Interesting...

- Jim
_________________
http://www.krazydad.com/
Back to top
View user's profile Send private message Visit poster's website
dukuso

Joined: 14 Jul 2005
Posts: 424
:
Location: germany

Items
PostPosted: Tue Aug 16, 2005 3:05 am    Post subject: Reply with quote

Merri's hardest are indeed so easy for me, that I already
wondered whether he posted the right sudokus :

1 sol. 64 nodes 0 guesses 15/91msec
1 sol. 222 nodes 23 guesses 70/91msec
1 sol. 64 nodes 0 guesses 85/91msec
1 sol. 270 nodes 21 guesses 145/91msec
1 sol. 93 nodes 4 guesses 165/91msec
1 sol. 64 nodes 0 guesses 180/91msec
1 sol. 64 nodes 0 guesses 195/91msec
1 sol. 70 nodes 1 guesses 210/91msec


or 1000 runs with randomized permuting of rows and columns of
the exact-cover matrix:
1000 sol. 64000 nodes 0 guesses 110/91sec
1000 sol. 254647 nodes 19267 guesses 265/91sec
1000 sol. 64000 nodes 0 guesses 375/91sec
1000 sol. 261019 nodes 21049 guesses 525/91sec
1000 sol. 76725 nodes 2207 guesses 640/91sec
1000 sol. 64000 nodes 0 guesses 750/91sec
1000 sol. 64000 nodes 0 guesses 855/91sec
1000 sol. 73606 nodes 1292 guesses 970/91sec


jburns list with 1000 randomized runs:
1000 sol. 375654 nodes 25162 guesses 175/91sec
1000 sol. 257631 nodes 16583 guesses 325/91sec
1000 sol. 211263 nodes 16759 guesses 460/91sec
1000 sol. 382634 nodes 22890 guesses 635/91sec
1000 sol. 130860 nodes 5175 guesses 760/91sec
1000 sol. 147835 nodes 7316 guesses 885/91sec
1000 sol. 236614 nodes 16593 guesses 1030/91sec
1000 sol. 322571 nodes 17719 guesses 1190/91sec
1000 sol. 204597 nodes 12290 guesses 1325/91sec
1000 sol. 189278 nodes 11842 guesses 1460/91sec
1000 sol. 170205 nodes 11033 guesses 1590/91sec
1000 sol. 247389 nodes 13812 guesses 1735/91sec
1000 sol. 231401 nodes 13036 guesses 1880/91sec
1000 sol. 147201 nodes 8869 guesses 2005/91sec
1000 sol. 272882 nodes 17727 guesses 2160/91sec
1000 sol. 177931 nodes 8312 guesses 2290/91sec
1000 sol. 278192 nodes 16798 guesses 2440/91sec
1000 sol. 182743 nodes 12197 guesses 2575/91sec
1000 sol. 397933 nodes 32238 guesses 2755/91sec
1000 sol. 106808 nodes 3647 guesses 2870/91sec
1000 sol. 148185 nodes 7333 guesses 2995/91sec
1000 sol. 227020 nodes 13012 guesses 3140/91sec
1000 sol. 266684 nodes 14423 guesses 3290/91sec
1000 sol. 250636 nodes 14521 guesses 3435/91sec
1000 sol. 275605 nodes 16662 guesses 3585/91sec
1000 sol. 266591 nodes 15609 guesses 3735/91sec
1000 sol. 138951 nodes 6323 guesses 3860/91sec
1000 sol. 173080 nodes 9732 guesses 3995/91sec
1000 sol. 117516 nodes 3381 guesses 4110/91sec
1000 sol. 214381 nodes 14026 guesses 4250/91sec
1000 sol. 273535 nodes 17396 guesses 4405/91sec
1000 sol. 188816 nodes 9898 guesses 4540/91sec



how did you make them ? how long did it take ?
Can you give the nodes or timings for them, so I
can compute the correlation coefficent between
our rating ? (mine vs. Merri's was earlier
computed as 0.4, but maybe with an older version)


Here are the hardest for my solver: http://magictour.free.fr/top100
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Tue Aug 16, 2005 5:36 am    Post subject: Reply with quote

> how did you make them ? how long did it take ?

My puzzle generator generates puzzles pretty quickly (a hundred
in a few seconds). If I filter for hard puzzles ( with > 20 mults - see below) then it generates one or two every minute or so.

My generation algorithm is based on a modified version of my DXL solver.

1) I start with a puzzle that has 1-9 in the top row, and the rest blank.

2) I solve it, stopping prematurely when I hit the first solution (there will
be many solutions). While solving it, I select nodes randomly (but do so
in such a way so that generating the puzzle doesn't take a long time).

3) I remove numbers in symetrical pairs, until I can't find a pair I can remove (without making more than one solution). In one version, when I remove these pairs, I select pairs that lead to harder puzzles. This slows down the puzzle generation, but may produce somewhat harder puzzles.

4) When the puzzle is done, I transliterate the numbers randomly, so that
it doesn't have 1-9 in the top row. Sometimes I skip this step, if I want
to compare the puzzles to each other for patterns.

> Can you give the nodes or timings for them

The timings aren't really relevent, since our computers are different speeds.

Here are some new puzzles I generated today (the first few are harder than the ones above), which include some stats. Not all of these are transliterated.

Code:

...4.8....4..5..1.3.96..4..6.......5..7...1..9.......4..1..78.3.6..8..4....2.1...  // mults=153 covers=9268
..65.3.......6.7..5.8....1636..2.......4.1.......3..2567....2.8..4.7.......2.65..  // mults=116 covers=6972
1.34.6..9.....2.6.6...93....5...1...2.1...4.6...2...3....52...4.1.6.....4..3.96.7  // mults=115 covers=5453
12....7.9.4...72..8.........7..1..6.3.......5.6..4..2.........8..53...7.7.2....46  // mults=86 covers=3682
....5..89.87....6.4..83.5..3......2...5.2.1...1......4..4.75..1.9....35.25..9....  // mults=89 covers=4239
294......6...9...4...43.......1...2.9...2...1.5..69.......76...8...1...5......837  // mults=83 covers=4180
........976..2...58...9312.6...7..53.........59..8...7.3526...89...4..622........  // mults=79 covers=4005
.2..5.78....9...6...8..2...31...76...4.....7...73...21...8..9...9...5....84.7..1.  // mults=72 covers=3728
........9.4.7.15.3..73....6..2.6.3...3.....5...5.2.4..3....89..2.49.5.3.9........  // mults=67 covers=3621
..3..6..95..2..6...6.....2.2..9.....74..8..96.....1..5.1.....7...7..9..14..1..3..  // mults=63 covers=3957
.23..6...7.59..4..9.4..1...4..6......3.....6......5..4...8..2.6..1..28.7...3..54.  // mults=61 covers=4271
..3..67.9....73.26.7.........1..9.787.......184.6..9.........1.49.83....3.75..8..  // mults=60 covers=2816


In the comments, "mults" means the number of times a node was generated containing more than 1 choice. Node count is basically going to be 81 + mults. The first puzzle I posted in this thread had 51 mults.

Covers indicates the number of times the dancing-links 'cover' operation was called - a metric used by Knuth in his paper.

I'm sending you my test-bed code so you can compare apples to apples.
_________________
http://www.krazydad.com/


Last edited by jbum on Tue Aug 16, 2005 7:10 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
Simes

Joined: 08 Apr 2005
Posts: 71
:
Location: North Yorkshire, UK

Items
PostPosted: Tue Aug 16, 2005 7:03 am    Post subject: Reply with quote

jbum wrote:
3) I remove numbers in symetrical pairs, until I can't find a pair I can remove. In one version, when I remove these pairs, I select pairs that lead to harder puzzles. This slows down the puzzle generation, but produces somewhat harder puzzles.

Extremely curious about this... how do you know which pairs will lead to harder puzzles? Have you identified some pattern?
_________________
Simes
www.sadmansoftware.com/sudoku
Back to top
View user's profile Send private message Visit poster's website
jbum

Joined: 14 Aug 2005
Posts: 14
:
Location: Los Angeles

Items
PostPosted: Tue Aug 16, 2005 7:07 am    Post subject: Reply with quote

Sorry, I mean I remove pairs I *hope* will lead to harder puzzles. I do this by testing the removal of all possible pairs, and then choosing the pair that produced the most backtracking.

This slows down puzzle generation however. I'm not yet convinced that simply producing random puzzles (which is much faster) and then filtering the difficult ones out isn't just as effective.
_________________
http://www.krazydad.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Puzzles All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron