MinLex Routine

Programs which generate, solve, and analyze Sudoku puzzles

Re: MinLex Routine

Postby swb01 » Sat May 07, 2022 1:17 pm

Hi coloin,
If any, my 5th step might be more useful since the 4th step is not an isomorph of the original puzzle.

Can you help me with a question I have about pattern processing? For a puzzle to match a pattern, must it be minimal?
If not, if a non-minimal puzzle matches a given pattern, is it said that a minimal sub-puzzle of that puzzle also matches the pattern?

Here's an example using your sample puzzle above:
Code: Select all
Original 18C Puzzle.
FullGrid: 327685194561394728849172563784913256295468317136257489978531642612749835453826971
Clues:    .2..8.1.............9....63.8..1.2.............6..7..9..........1..4.8....3..6.7.
    -------------------------------
    | 3 (2) 7 | 6 (8) 5 |(1) 9  4 |
    | 5  6  1 | 3  9  4 | 7  2  8 |
    | 8  4 (9)| 1  7  2 | 5 (6)(3)|
    -------------------------------
    | 7 (8) 4 | 9 (1) 3 |(2) 5  6 |
    | 2  9  5 | 4  6  8 | 3  1  7 |
    | 1  3 (6)| 2  5 (7)| 4  8 (9)|
    -------------------------------
    | 9  7  8 | 5  3  1 | 6  4  2 |
    | 6 (1) 2 | 7 (4) 9 |(8) 3  5 |
    | 4  5 (3)| 8  2 (6)| 9 (7) 1 |
    -------------------------------
It's 27C diagonal happens to solve the puzzle, but its not minimal
Clues:    ..7..5..4.6..9..2.8..1..5....4..3..6.9..6..1.1..2..4....8..1..2.1..4..3.4..8..9..
    -------------------------------
    | 3  2 (7)| 6  8 (5)| 1  9 (4)|
    | 5 (6) 1 | 3 (9) 4 | 7 (2) 8 |
    |(8) 4  9 |(1) 7  2 |(5) 6  3 |
    -------------------------------
    | 7  8 (4)| 9  1 (3)| 2  5 (6)|
    | 2 (9) 5 | 4 (6) 8 | 3 (1) 7 |
    |(1) 3  6 |(2) 5  7 |(4) 8  9 |
    -------------------------------
    | 9  7 (8)| 5  3 (1)| 6  4 (2)|
    | 6 (1) 2 | 7 (4) 9 | 8 (3) 5 |
    |(4) 5  3 |(8) 2  6 |(9) 7  1 |
    -------------------------------
21C minimal sub-puzzle #1.
Clues:    ..7.....4.6..9..2.8..1..5.......3..6.9..6..1.1.....4....8.......1.....3.4..8..9..
    -------------------------------
    | 3  2 (7)| 6  8  5 | 1  9 (4)|
    | 5 (6) 1 | 3 (9) 4 | 7 (2) 8 |
    |(8) 4  9 |(1) 7  2 |(5) 6  3 |
    -------------------------------
    | 7  8  4 | 9  1 (3)| 2  5 (6)|
    | 2 (9) 5 | 4 (6) 8 | 3 (1) 7 |
    |(1) 3  6 | 2  5  7 |(4) 8  9 |
    -------------------------------
    | 9  7 (8)| 5  3  1 | 6  4  2 |
    | 6 (1) 2 | 7  4  9 | 8 (3) 5 |
    |(4) 5  3 |(8) 2  6 |(9) 7  1 |
    -------------------------------
21C minimal sub-puzzle #2.
Clues:    ..7.....4.6..9.......1..5.......3..6.9..6..1.1..2..4....8.....2.1.....3.4..8..9..
    -------------------------------
    | 3  2 (7)| 6  8  5 | 1  9 (4)|
    | 5 (6) 1 | 3 (9) 4 | 7  2  8 |
    | 8  4  9 |(1) 7  2 |(5) 6  3 |
    -------------------------------
    | 7  8  4 | 9  1 (3)| 2  5 (6)|
    | 2 (9) 5 | 4 (6) 8 | 3 (1) 7 |
    |(1) 3  6 |(2) 5  7 |(4) 8  9 |
    -------------------------------
    | 9  7 (8)| 5  3  1 | 6  4 (2)|
    | 6 (1) 2 | 7  4  9 | 8 (3) 5 |
    |(4) 5  3 |(8) 2  6 |(9) 7  1 |
    -------------------------------

swb01
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

Re: MinLex Routine

Postby coloin » Wed May 11, 2022 4:34 pm

I think its ok for a puzzle to be non-minimal ... if it is valid and it matches the pattern then it just means there can be derived smaller puzzles ... these will obviously have a different pattern.
coloin
 
Posts: 2494
Joined: 05 May 2005
Location: Devon

Re: MinLex Routine

Postby coloin » Wed May 11, 2022 4:57 pm

gsf's program command to get min lex pattern
Code: Select all
sudoku-64 -f%#xc   print minlex pattern  [as x]
sudoku-64 -f%#xc   file.txt > pattern.txt
coloin
 
Posts: 2494
Joined: 05 May 2005
Location: Devon

Re: MinLex Routine

Postby swb01 » Thu May 12, 2022 12:18 pm

My minlex program will also minlex a pattern - if all x’s are changed to all 1’s. Maybe I’ll add a x-pattern option to the program if that will make it more useful.
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

Postby 1to9only » Tue May 17, 2022 10:36 am

When I run the program I get this:
Code: Select all
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [D:\MinLex9x9SR1\MinLexDriver_Executables\].
If this is a framework-dependent application, install the runtime in the global location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation].

The .NET runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win10-x64&apphost_version=6.0.3

I don't really want to install .NET on PC.
Can a self-contained program be provided?
Thanks.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Re: MinLex Routine

Postby swb01 » Tue May 17, 2022 12:03 pm

1to9only,
I apologize for my program not working for you. I’ll try to figure out how to publish a self contained application and post an update.
swb01
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

Postby 1to9only » Tue May 17, 2022 5:18 pm

1to9only wrote:I don't really want to install .NET on PC.

I have a minimal VS 2019 Community Edition installed, just enough to build projects from the command line.
I see VS 2022 17.2 was released very recently, I'll install the Community Edition sometime, and then try build the minlexer.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Postby 1to9only » Wed May 18, 2022 8:31 am

1to9only wrote:Can a self-contained program be provided?

I no longer need this as I've installed VS2022 (17.2) and am able to build and run the minlexer.
Thanks for looking into this.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Re: MinLex Routine

Postby swb01 » Wed May 18, 2022 11:22 am

1to9only,
Good to know you got it going.
After you work with the program some, I would be interested in some feedback on the usefulness of the program (and anyone else that tries the program). How does the program fit into your area of interest activities? Are there changes that would make it more useful? Do you use the command line feature? Are the instructions for use clear?

I’m working on another release with two minor changes that should be ready in a few days. 1. Publish it as a self-contained .exe. 2) Provide explicit pattern mode that will accept 81 character lines with 0s or periods and anything treated as an X.
swb01
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

Postby 1to9only » Wed May 18, 2022 12:38 pm

Currently in the Patterns Game I use gsf's sudoku.exe (row minlex) to detect isomorphs of puzzles before submitting. This works pretty good.

I'm trying to switch to 'true' minlex for the process, of which there are currently 3 programs that will do the job:

- [cpp] kaityo256's which I've forked here - there is a Windows exe in Releases section that will do the job of gsf's sudoku.exe.

- [Rust + python bindings] dclamage's minlexer here - I have a python front-end that will also do the job of gsf's sudoku.exe, but it is slower as noted here. Cons: 2 python files solution.

- [C#] this swb01's minlexer here. I've modified Driver enough for it to take a filename argument to maybe do the job of sudoku.exe. Pros: Multi-threaded. Cons: Expects one sudoku per line + CRLF termination. Not a one-file solution. Going Forward: I can probably replace Driver with my own front-end to call the minlexer!

Note: All the programs probably have other uses like pattern and solution minlexing, but I've not tried these.
Last edited by 1to9only on Wed Jun 29, 2022 7:54 am, edited 2 times in total.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Re: MinLex Routine

Postby swb01 » Wed May 18, 2022 2:36 pm

1to9only,
Thanks for your feedback and survey of minlexers.
Are you using the C# version I posted last August at release 2 or did you generate a C# clone of the March 30 release3? (I maintain the minlexer in Visual Basic and I failed to provide a C# clone for release3. I will do so for future releases.)
Release3 is significantly faster than release2 with the performance improvements happening in the subroutine but mostly in the driver.
Also, release 3 now includes a command line option that you seem to have coded for.

1to9only wrote: Cons: Expects one sudoku per line + CRLF termination. Not a one-file solution.

I don't understand "Not a one-file solution." I thought its input .txt file format was fairly standard for puzzle interchange.
swb01
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

Re:

Postby m_b_metcalf » Wed May 18, 2022 4:07 pm

1to9only wrote:Currently in the Patterns Game I use gsf's sudoku.exe (row minlex) to detect isomorphs of puzzles before submitting. This works pretty good.

In order to check my own min_lex program I decided to test it on the Patterns Game patterns file that g.r.emlin can be requested to provide. The first part of each entry is the minlex version of the pattern; the second is the puzzle submitted by the dealer. I was happy to find that the two programs gave identical results, apart from the numbered game 16:
Code: Select all
100001001001010010010100100001010010010100100100001001001010010010100100100001001
100200300020010040003005006700600500050080070008004001800700400030060020009002007
102/102/102 da 2008002002+05:31:0000000 Mauricio 0016

It looks as though gsf's program doesn't get that one right.

Regards,

Mike
User avatar
m_b_metcalf
2017 Supporter
 
Posts: 13621
Joined: 15 May 2006
Location: Berlin

Postby 1to9only » Wed May 18, 2022 4:38 pm

swb01 wrote:did you generate a C# clone of the March 30 release3?

I downloaded zip file of the whole project off google drive, and just grabbed the cs files to use. Yes, the Driver says CS-2022_03_30.
swb01 wrote:I don't understand "Not a one-file solution."

Ideally I do (maybe others as well) want a single .exe file to download and run with no extras to download and/or install.
swb01 wrote:I thought its input .txt file format was fairly standard for puzzle interchange.

Agreed. But I tend to add text to the file to show origins (webpage/post) of puzzles. The text is usually less than 81 characters per line, so these get skipped over!
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Re: MinLex Routine

Postby swb01 » Wed May 18, 2022 5:06 pm

1to9only,
- Ahh. I forgot that I did provide the C# version with my March 30 release. However, I added the command line arguments to the VB driver on April 1 and failed to update the C# version. (edit #1)
- I mistakenly thought "Not a one-file solution" was referring to the fixed length input format comment that preceded it. Thanks for clarifying. I agree a self-contained .exe file would be helpful and I'll get one out there soon.
- On the fixed-length input file requirement. It's a performance consideration. The fixed length allows for large block streamwriter I/O.
Thanks for the clarifications,
swb01
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

Re: MinLex Routine

Postby swb01 » Mon May 23, 2022 5:31 pm

I uploaded release4 to the GDrive today, (see first post for link.)
Added pattern processing and self-contained executables.
swb01
 
Posts: 47
Joined: 07 March 2021
Location: Potomac, Maryland

PreviousNext

Return to Software