ogarcia / opensudoku

Open Source Sudoku game for Android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: import hodoku format puzzles

jthornhill opened this issue · comments

OpenSudoku is great and the online puzzle generator is very helpful!

However, if you're trying to learn specific advanced solving techniques, you may want to train on puzzles that you know highlight the technique you are working with. Specifically, Hodoku is a popular generator / solver written in Java which supports generating puzzles specifically for learning.

There exists a Python script to convert these files already (sample files are included in that repo too). It's a pretty straightforward conversion, and that script is pretty simple.

Obviously this means one can already get such puzzles into OpenSudoku :) But, it's not going to be obvious for non-technical users how to do it. Supporting this format natively would be great!

I don't know what format of file generates Hodoku, seems that support sdm, you can import sdm files directly to OpenSudoku

An SDM file is described here but basically is a txt file with each line is a puzzle and zeroes represent empty cells. For example this line

016400000200009000400000062070230100100000003003087040960000005000800007000006820

Are translated to:

016   400   000 
200   009   000
400   000   062

070   230   100
100   000   003
003   087   040

960   000   005
000   800   007
000   006   820

If Hodoku exports these files but with txt extension you only have to change the extension to import it in Open Sudoku

I don't know what format of file generates Hodoku, seems that support sdm, you can import sdm files directly to OpenSudoku

An SDM file is described here but basically is a txt file with each line is a puzzle and zeroes represent empty cells. For example this line

016400000200009000400000062070230100100000003003087040960000005000800007000006820

This is really great info, thanks!

The default output of the Hodoku generator (when run on the command line) just looks like a variant of SDM, using . instead of 0, with comments on the end. Like so:

...3.8.4..9352....8..........1..5.796......2....8.1............94.1..3....7.3.65. # ssts bf3(5) x
..7.6314....1....2....98...5.....2..2.....4.66..48....143....9.........3.6.5..... # x bf3(1) x
.98....6....41..5........192...5..3....9.8..2..634...585....39...7.............84 # x bf3(1) x
..4..3.29.7....358............83.6..5......1.8.25....491.2.......3987............ # x bf3(2) x

Just doing s/\./0/g and naming it to the sdm file extension does the trick (I stripped the comments too, but dunno if that was required).

I don't know if there's a spec/reference implementation of the sdm format, but this feature request may really be "support . in addition to 0 as a placeholder in SDM files." The SudoCue docs mention that they support the . in exchange for 0 too, so there may be other generators that do this:

This is a very simple format. Each line contains a single puzzle. The empty cells are represented by a zero, but the program also accepts other placeholders, like a dot “.”. Line breaks in Windows or Unix style are recognized, but when my software writes these files, CrLb is always used. These files cannot be written by SudoCue. The program can only read them.

Done, in next release you will can import a .sdm file that use dots instead of zeros, but you must remove comments since the format doesn't accept it.