## Finding a puzzle based on known given squares

Everything about Sudoku that doesn't fit in one of the other sections

### Finding a puzzle based on known given squares

Good evening,
Is there any way to find if a particular pattern of givens can produce a valid Sudoku puzzle?

I have the following 23-clue pattern, and want to know if a valid board can be created from it:
Code: Select all
`...|XXX|..X...|X..|..XXX.|...|..X---+---+---XX.|..X|......|.X.|......|X..|.XX---+---+---X..|...|.XXX..|..X|...X..|XXX|...`

I'm also curious if there's some known algorithm that could do a search based on given locations to check for a valid puzzle.
Aranlyde

Posts: 1
Joined: 16 April 2020

### Re: Finding a puzzle based on known given squares

Yes there are many puzzles with that pattern.
A 20 clue pattern might have 1M puzzles most of them minimal

Code: Select all
`+---+---+---+|...|765|..8||...|9..|..2||14.|...|..9|+---+---+---+|26.|..3|...||...|.7.|...||...|4..|.51|+---+---+---+|3..|...|.26||4..|..8|...||5..|214|...|+---+---+---+`

your pattern has 23 clues and for whatever reason ...... most of them are non minimal [have superfluos clues], and inherently easy solved with singles

puzzles are made with computor programs .... I have a program which I can put in the software section for anyone
coloin

Posts: 1951
Joined: 05 May 2005

### Re: Finding a puzzle based on known given squares

Put the pattern into a text file, e.g. pattern.txt:
Code: Select all
`...XXX..X...X....XXX......XXX...X.......X.......X...XXX......XXX....X...X..XXX...`

Run 'gsf.exe --help' for program options, redirecting the output to a text file is recommended.
Run this command to generate 100 unique and minimal puzzles for the given pattern:
Code: Select all
`gsf.exe -n100 -gt -euniq()*(1==minimal) < pattern.txt > puzzles.txt`

Sample puzzles.txt:
Hidden Text: Show
Code: Select all
`...847..1...9....786......973...5.......2.......3...629......735....4...6..138... #    14 FN C25.m/S2.p...287..5...1....986......361...5.......6.......9...744......285....4...3..728... #     9 FN C25.m/S2.p...591..6...2....569......173...9.......3.......6...482......678....2...9..174... #    12 FN C25.m/S2.p...526..3...7....218......571...4.......9.......8...345......672....8...3..967... #    13 FN C25.m/S2.p...379..2...6....879......383...2.......1.......7...644......315....1...3..295... #    12 FN C25.m/S2.p...386..9...5....286......797...1.......5.......8...364......237....8...6..192... #  2144 FNBTHWXY C25.m/S2.p...417..2...2....312......587...6.......8.......9...516......349....4...7..893... #    22 FN C25.m/S2.p...279..8...6....513......697...5.......3.......4...125......618....6...6..382... #    12 FN C25.m/S2.p...216..4...4....634......919...7.......5.......8...359......714....1...5..378... #    13 FN C25.m/S2.p...816..3...7....275......619...3.......6.......5...619......273....5...4..392... #    15 FN C25.m/S2.p...615..4...4....952......691...4.......9.......1...928......753....6...4..732... #    21 FNB C25.m/S2.p...672..1...9....347......219...7.......6.......1...562......453....8...7..254... #    11 FN C25.m/S2.p...743..9...6....167......235...1.......8.......3...872......435....2...4..196... #    22 FNB C25.m/S2.p...268..1...4....829......764...1.......5.......7...328......297....4...5..612... #   541 FNTXY C25.m/S2.p...849..2...3....415......867...4.......7.......2...169......215....7...3..182... #   280 FNTY C25.m/S2.p...763..5...1....349......137...6.......1.......3...428......649....8...5..649... #    14 FN C25.m/S2.p...812..3...6....598......187...6.......4.......5...962......196....4...4..279... #    10 FN C25.m/S2.p...192..5...6....859......796...8.......4.......5...844......593....4...2..735... #    14 FN C25.m/S2.p...754..6...6....258......945...3.......7.......4...518......346....9...3..581... #    12 FN C25.m/S2.p...628..7...4....964......839...5.......4.......7...612......135....9...4..371... #    21 FN C25.m/S2.p...148..5...9....349......786...4.......3.......8...723......462....5...5..317... #    15 FN C25.m/S2.p...496..2...1....814......331...5.......3.......7...692......516....8...5..927... #    19 FN C25.m/S2.p...684..1...7....482......319...8.......1.......9...153......874....5...9..342... #    11 FN C25.m/S2.p...349..2...1....675......946...8.......6.......2...711......859....1...5..827... #    12 FN C25.m/S2.p...842..5...3....296......367...9.......7.......2...791......865....4...7..125... #    14 FN C25.m/S2.p...542..9...3....463......117...4.......1.......8...468......524....5...5..278... #    21 FNB C25.m/S2.p...238..5...5....458......642...9.......5.......4...821......496....4...8..176... #  1122 FNBTHWY C25.m/S2.p...526..8...3....249......395...1.......7.......8...313......845....3...2..954... #   337 FNBHY C25.m/S2.p...736..1...4....589......724...1.......9.......5...183......621....5...4..267... #    11 F C25.m/S2.p...854..3...6....763......829...8.......2.......9...658......497....1...5..796... #    11 FN C25.m/S2.p...798..1...4....378......262...3.......7.......5...393......461....4...2..835... #   422 FNBTHX C25.m/S2.p...415..7...3....842......113...7.......9.......1...368......245....4...7..862... #    12 FN C25.m/S2.p...647..1...5....213......428...3.......6.......2...675......239....2...7..195... #    13 FN C25.m/S2.p...589..1...1....379......614...2.......1.......6...272......346....3...8..796... #    12 FN C25.m/S2.p...579..3...3....297......676...3.......5.......7...182......498....2...6..915... #    20 FNB C25.m/S2.p...173..9...2....564......171...5.......2.......9...748......365....2...1..734... #     8 F C25.m/S2.p...983..1...2....478......684...5.......2.......1...984......736....1...5..732... #    18 FNB C25.m/S2.p...671..9...3....812......738...9.......3.......4...729......457....5...8..164... #     9 FN C25.m/S2.p...734..5...9....429......696...2.......9.......4...516......783....1...4..657... #    15 FN C25.m/S2.p...953..2...6....459......116...8.......4.......1...298......569....7...4..526... #   235 FNBTH C25.m/S2.p...836..2...4....135......992...4.......5.......7...388......971....7...4..683... #    12 FN C25.m/S2.p...623..9...4....576......117...8.......9.......2...538......763....4...6..739... #   277 FNBY C25.m/S2.p...359..1...1....672......935...8.......1.......6...546......928....6...1..723... #    18 FNB C25.m/S2.p...146..2...5....643......578...5.......9.......3...749......175....7...2..981... #    19 FN C25.m/S2.p...619..3...8....476......282...1.......4.......9...153......475....6...9..237... #    14 FN C25.m/S2.p...476..3...3....564......797...8.......9.......1...565......618....4...2..863... #    10 FN C25.m/S2.p...216..7...4....516......947...5.......3.......8...927......146....9...5..147... #   234 FNBTH C25.m/S2.p...986..4...1....269......347...9.......2.......3...895......173....5...9..831... #    10 FN C25.m/S2.p...671..2...5....491......523...9.......4.......7...585......167....4...1..368... #    15 FN C25.m/S2.p...479..6...2....543......926...1.......2.......7...585......813....2...9..513... #   275 FNBY C25.m/S2.p...178..4...5....651......796...5.......9.......4...288......627....1...3..924... #  1041 FNTWY C25.m/S2.p...759..8...3....756......119...8.......9.......5...294......326....3...8..146... #   280 FNBTY C25.m/S2.p...915..7...6....296......541...8.......7.......2...387......542....7...3..194... #    14 FN C25.m/S2.p...328..5...6....293......116...2.......8.......4...794......963....5...8..169... #    21 FNB C25.m/S2.p...432..8...9....432......551...6.......9.......8...697......529....1...8..627... #    11 FN C25.m/S2.p...516..8...4....581......393...7.......5.......9...266......397....8...3..692... #    16 FN C25.m/S2.p...493..8...8....782......567...1.......7.......9...145......369....8...7..312... #    15 FN C25.m/S2.p...687..2...1....697......824...3.......6.......4...591......874....2...7..358... #   267 FNBY C25.m/S2.p...145..7...8....631......589...6.......8.......9...517......236....2...9..751... #    37 FNBT C25.m/S2.p...612..9...3....857......148...5.......3.......2...171......927....9...9..824... #    14 FN C25.m/S2.p...652..8...4....539......656...9.......1.......8...432......314....7...7..238... #    10 F C25.m/S2.p...263..4...8....297......654...9.......8.......3...894......158....6...2..951... #    15 FN C25.m/S2.p...489..3...7....586......424...8.......9.......6...313......785....4...6..531... #   528 FNBXY C25.m/S2.p...276..4...5....174......531...9.......1.......4...921......682....4...9..823... #    11 FN C25.m/S2.p...536..8...8....487......172...9.......6.......2...935......871....5...6..417... #    12 FN C25.m/S2.p...849..5...1....917......291...6.......8.......3...514......672....5...3..624... #    14 FN C25.m/S2.p...821..7...5....635......889...4.......7.......1...839......316....7...7..395... #    11 FN C25.m/S2.p...697..2...5....847......513...6.......1.......2...147......318....1...6..758... #   277 FNBY C25.m/S2.p...319..2...6....189......345...6.......9.......4...757......582....1...3..582... #    12 FN C25.m/S2.p...678..9...4....537......429...6.......8.......5...416......578....3...1..957... #    17 FN C25.m/S2.p...294..1...1....752......446...1.......8.......7...393......768....6...2..438... #    12 F C25.m/S2.p...643..2...2....163......759...8.......7.......9...141......853....4...9..315... #   275 FNBX C25.m/S2.p...627..5...9....263......921...3.......8.......1...733......261....8...7..264... #    16 FN C25.m/S2.p...928..4...1....986......765...3.......1.......8...427......852....9...3..285... #    18 FNB C25.m/S2.p...195..2...3....846......382...6.......7.......4...697......541....8...2..513... #    15 FN C25.m/S2.p...713..2...5....715......938...2.......4.......3...486......248....9...9..167... #    17 FN C25.m/S2.p...287..5...3....684......749...2.......3.......6...825......147....6...3..845... #    17 FN C25.m/S2.p...975..6...8....249......852...8.......9.......5...477......319....2...8..314... #  1117 FNBHY C25.m/S2.p...432..7...1....249......124...5.......1.......6...838......293....7...1..958... #   281 FNBTY C25.m/S2.p...459..2...8....623......958...4.......6.......2...481......759....5...4..791... #    10 FN C25.m/S2.p...758..3...6....148......629...6.......7.......8...973......427....3...8..514... #    13 FN C25.m/S2.p...561..2...2....762......489...2.......5.......9...657......134....6...3..745... #     9 FN C25.m/S2.p...237..8...1....237......421...9.......8.......5...376......497....4...9..316... #    14 FN C25.m/S2.p...271..6...5....236......117...2.......8.......3...799......687....4...4..825... #    11 FN C25.m/S2.p...452..8...8....498......173...1.......4.......7...931......254....8...6..573... #    11 FN C25.m/S2.p...851..9...4....831......743...2.......4.......7...929......617....5...6..318... #    11 FN C25.m/S2.p...196..2...7....482......938...1.......6.......9...864......739....7...6..425... #    41 FNBT C25.m/S2.p...726..8...5....257......126...7.......6.......8...577......149....4...6..281... #    51 FNBT C25.m/S2.p...916..2...3....751......887...2.......3.......7...619......247....3...3..624... #    10 FN C25.m/S2.p...937..1...8....532......987...9.......7.......2...541......637....1...9..653... #    10 FN C25.m/S2.p...546..3...8....789......142...5.......6.......2...191......459....3...3..128... #    12 FN C25.m/S2.p...839..2...2....431......693...6.......4.......9...585......374....2...2..318... #    17 FNB C25.m/S2.p...791..4...8....315......298...4.......7.......5...673......892....7...6..318... #    11 FN C25.m/S2.p...361..9...7....461......293...6.......4.......2...518......472....3...3..479... #    15 FNB C25.m/S2.p...713..4...4....813......656...9.......3.......8...919......732....8...4..597... #    11 FN C25.m/S2.p...154..9...2....798......421...5.......6.......3...788......315....9...7..843... #    16 FNB C25.m/S2.p...492..8...7....627......541...5.......2.......8...536......127....4...3..186... #    14 FN C25.m/S2.p...163..7...2....641......538...9.......5.......8...921......438....4...2..631... #    18 FN C25.m/S2.p...815..3...6....725......642...3.......6.......2...788......149....4...1..987... #    12 FN C25.m/S2.p...769..3...8....194......663...7.......3.......5...683......498....1...2..976... #    14 FN C25.m/S2.p`

.
1to9only

Posts: 2267
Joined: 04 April 2018

### Re: Finding a puzzle based on known given squares

coloin wrote:I have a program which I can put in the software section for anyone

Hi coloin
Can your program run on Unix / MacOS? If yes, I'm interested.
I remember using gsf's program for this purpose, but I'm unable to find it (the link in the other answer is only for Windows).
denis_berthier
2010 Supporter

Posts: 2000
Joined: 19 June 2007
Location: Paris

### Re: Finding a puzzle based on known given squares

Hi Denis,

denis_berthier wrote:
coloin wrote:I have a program which I can put in the software section for anyone

Hi coloin
Can your program run on Unix / MacOS? If yes, I'm interested.
I remember using gsf's program for this purpose, but I'm unable to find it (the link in the other answer is only for Windows).

If you do find a non-Windows version of gsf's program, please let me know. Of course there are many ways to run Windows (or just Windows programs) on a Mac, but I've been too lazy and too allergic to do it. Apparently so have you. I'm still planning to do so at some point, because I'd like to test e.g. XSudo and YZF_Sudoku too. I haven't yet gathered enough motivation, even though I'm sure both programs are really good

Btw, if you don't want to install Windows on your own machine (even in a VM), you can always get a cloud instance and use it there if you don't mind the network lag. It's possible in both AWS and Azure (of course), for example.

SpAce

Posts: 2674
Joined: 22 May 2017

### Re: Finding a puzzle based on known given squares

SpAce wrote:If you do find a non-Windows version of gsf's program, please let me know. Of course there are many ways to run Windows (or just Windows programs) on a Mac, but I've been too lazy and too allergic to do it. Apparently so have you. I'm still planning to do so at some point, because I'd like to test e.g. XSudo and YZF_Sudoku too. I haven't yet gathered enough motivation, even though I'm sure both programs are really good
Btw, if you don't want to install Windows on your own machine (even in a VM), you can always get a cloud instance and use it there if you don't mind the network lag. It's possible in both AWS and Azure (of course), for example.

I don't have enough motivations to install Windows on my Mac. I too would like to try XSudo (I tried the online version of YZF_Sudoku), but not enough to install Windows just for this purpose.

As for gsf's program, I may be wrong about using it on my Mac. I've been unable to find it. What I'm sure is, I used his sudz program (a decompressor) to generate full grids from his bands data. This was so long ago that I may be confusing the two.
denis_berthier
2010 Supporter

Posts: 2000
Joined: 19 June 2007
Location: Paris

### Re: Finding a puzzle based on known given squares

the gsf c source was posted here. it compiles fine in windows, so i think a unix/mac version should not be a problem.
1to9only

Posts: 2267
Joined: 04 April 2018

### gsf linux

I had used the linux version of gsf's program, called sudoku-linux.i386.
But it does not work anymore on 64 bit linux, needing the 32 bit version of libbz2.so.1, which i cannot install.
If you want to try, i have attached it.
Attachments
sudoku-linux.i386.zip
eleven

Posts: 2469
Joined: 10 February 2008

### Re: Finding a puzzle based on known given squares

1to9only wrote:the gsf c source was posted here. it compiles fine in windows, so i think a unix/mac version should not be a problem.

On my Mac (Catalina, 64bits), I can't even uncompress the 6 files.
denis_berthier
2010 Supporter

Posts: 2000
Joined: 19 June 2007
Location: Paris

### Re: gsf linux

eleven wrote:I had used the linux version of gsf's program, called sudoku-linux.i386.
But it does not work anymore on 64 bit linux, needing the 32 bit version of libbz2.so.1, which i cannot install.
If you want to try, i have attached it.

Thanks, but same as you. It can't run on 64-bit only Catalina version of MacOS
denis_berthier
2010 Supporter

Posts: 2000
Joined: 19 June 2007
Location: Paris

### Re: Finding a puzzle based on known given squares

1to9only wrote:the gsf c source was posted here. it compiles fine in windows, so i think a unix/mac version should not be a problem.

Yes, that worked, thanks:

cat ast-sudoku.2012-08-01.z01.zip ast-sudoku.2012-08-01.z02.zip ast-sudoku.2012-08-01.z03.zip ast-sudoku.2012-08-01.z04.zip ast-sudoku.2012-08-01.z05.zip ast-sudoku.2012-08-01.zip > gsf.7
7z e gsf.7
gcc sudzlib.c sudata.c subcanon.c sudoku.c -o gsf

Tested:
echo '...XXX..X...X....XXX......XXX...X.......X.......X...XXX......XXX....X...X..XXX...' > pattern.txt
./gsf -n100 -gt -euniq'()*(1==minimal)' < pattern.txt > puzzles.txt
eleven

Posts: 2469
Joined: 10 February 2008

### Re: Finding a puzzle based on known given squares

eleven wrote:
1to9only wrote:the gsf c source was posted here. it compiles fine in windows, so i think a unix/mac version should not be a problem.

Yes, that worked, thanks:
cat ast-sudoku.2012-08-01.z01.zip ast-sudoku.2012-08-01.z02.zip ast-sudoku.2012-08-01.z03.zip ast-sudoku.2012-08-01.z04.zip ast-sudoku.2012-08-01.z05.zip ast-sudoku.2012-08-01.zip > gsf.7

Until here OK, you turn the 6 files into one.

eleven wrote:7z e gsf.7

I tried to open it with Unarchiver and with Keka on my Mac, but both say the archive is incomplete.

I also tried unzip instead, and I get more detailed error messages:
Hidden Text: Show
Archive: gsf.7
warning [gsf.7]: zipfile claims to be last disk of a multi-part archive;
attempting to process anyway, assuming all parts have been concatenated
together in order. Expect "errors" and warnings...true multi-part support
doesn't exist yet (coming soon).
warning [gsf.7]: 972800 extra bytes at beginning or within zipfile
(attempting to process anyway)
(attempting to re-compensate)
creating: lib/
creating: lib/package/
inflating: lib/package/ast-sudoku.html
inflating: lib/package/ast-sudoku.pkg
extracting: lib/package/ast-sudoku.req
inflating: lib/package/ast-sudoku.ver
inflating: lib/package/ast.def
inflating: lib/package/ast.lic
inflating: lib/package/epl.def
creating: src/
creating: src/cmd/
creating: src/cmd/sudoku/
inflating: src/cmd/sudoku/bbss.c
inflating: src/cmd/sudoku/canon.c
inflating: src/cmd/sudoku/constraint_A.c
inflating: src/cmd/sudoku/constraint_J.c
inflating: src/cmd/sudoku/constraint_U.c
inflating: src/cmd/sudoku/constraint_Z.c
creating: src/cmd/sudoku/data/
inflating: src/cmd/sudoku/data/m-2.dat
inflating: src/cmd/sudoku/data/m-54.dat
inflating: src/cmd/sudoku/data/multiple-1.tst
inflating: src/cmd/sudoku/data/multiple-2.tst
inflating: src/cmd/sudoku/data/png
inflating: src/cmd/sudoku/data/w-1.dat
inflating: src/cmd/sudoku/data/x-1.dat
inflating: src/cmd/sudoku/data/x-2.dat
inflating: src/cmd/sudoku/data/y-1.dat
inflating: src/cmd/sudoku/data/y-2.dat
inflating: src/cmd/sudoku/faq.sudoku.mm
inflating: src/cmd/sudoku/Makefile
inflating: src/cmd/sudoku/Mamfile
inflating: src/cmd/sudoku/NOTES
inflating: src/cmd/sudoku/pseudocoup.c
inflating: src/cmd/sudoku/pseudocoup.rt
inflating: src/cmd/sudoku/pseudocoup.tst
inflating: src/cmd/sudoku/RELEASE
inflating: src/cmd/sudoku/subcanon.c
(attempting to re-compensate)
inflating: src/cmd/sudoku/testsudocoup.out
inflating: src/cmd/sudoku/testsudocoup.sh
inflating: src/cmd/sudoku/testsudoku.out
inflating: src/cmd/sudoku/testsudoku.sh

eleven wrote:gcc sudzlib.c sudata.c subcanon.c sudoku.c -o gsf

As should be expected from the previous messages, errors here also
Hidden Text: Show
clang: error: no such file or directory: 'sudzlib.c'
clang: error: no such file or directory: 'sudata.c'
clang: error: no such file or directory: 'subcanon.c'
clang: error: no such file or directory: 'sudoku.c'
clang: error: no input files
denis_berthier
2010 Supporter

Posts: 2000
Joined: 19 June 2007
Location: Paris

### Re: Finding a puzzle based on known given squares

I am sorry, Denis. Since i had encountered errors, when i wanted to uncompress it, i tried different things, and at the end i did not know, which one worked. (The way i thought is my normal way to unzip multiple parts of 7z-compressed data).

But it should work like R. Jamil said, though it cannot be extracted with unzip, which confused me.

mv ast-sudoku.2012-08-01.z02.zip ast-sudoku.2012-08-01.z02
mv ast-sudoku.2012-08-01.z01.zip ast-sudoku.2012-08-01.z01
mv ast-sudoku.2012-08-01.z03.zip ast-sudoku.2012-08-01.z03
mv ast-sudoku.2012-08-01.z04.zip ast-sudoku.2012-08-01.z04
mv ast-sudoku.2012-08-01.z05.zip ast-sudoku.2012-08-01.z05

eleven

Posts: 2469
Joined: 10 February 2008

### Re: Finding a puzzle based on known given squares

I've repackaged the 6 files into a single zip file - Download from here.
It is on a free file storage web site, and it will be deleted after about 2 weeks.

file: ast-sudoku.2012-08-01.zip
size: 1,191,372 bytes
md5: b2b1c5c9b51771b2c2a2f7136045047b
1to9only

Posts: 2267
Joined: 04 April 2018

### Re: Finding a puzzle based on known given squares

Hi eleven and 1to9only,
thanks to both of you.
It works.
denis_berthier
2010 Supporter

Posts: 2000
Joined: 19 June 2007
Location: Paris

Next