Using Ssudoku

Ssudoku is a command line program that can be used either to solve puzzles, or to generate new ones so that you can solve them.

The --html (-h) option

By default, Ssudoku generates puzzles on the terminal using ASCII art e.g:


------------------
|   |   ||   |   |
| 1 |   || 4 |   |
|   |   ||   |   |
------------------
|   |   ||   |   |
|   | 2 ||   | 1 |
|   |   ||   |   |
==================
|   |   ||   |   |
| 2 |   ||   |   |
|   |   ||   |   |
------------------
|   |   ||   |   |
| 3 |   ||   |   |
|   |   ||   |   |
------------------

The --html option (or the shortened -h variant) tells Ssudoku to generate html instead. This is even less readable, but looks a lot better when saved to a file, and viewed through your favourite web browser.

Technically Sudoku generates an HTML fragment - the headers and footers normally found in an HTML file are not present, but most web browsers will display it in any case, and this format makes it easier to include the HTML into another web page.

Using Ssudoku to Solve Puzzles

Using Ssudoku to solve a puzzle is as simple as running:

ssudoku <filename>

where <filename> is the name of the text file containing the puzzle. Of course, the obvious question is what goes in that file?

Taking the example of a 3x3 puzzle (i.e. 3x3 squares each of 3x3 cells) then you need 9 rows, each of which consists of exactly nine characters, each of which is a digit in the range 1-9, or a space.

So the example puzzle on the front page of this site would be specified as:-

8  74163 
    3   8
9    27  
1 49 3   
  5 749  
  6   17 
  8 1    
41  96 85
 3 5     

Don't forget that each line must be exactly nine characters - even if the last characters(s) on a line is(are) a space.

When ssudoku finishes solving the puzzle, it will print out the solution, and also give a rating on how difficult the puzzle was. The more sophisticated the techniques required to solve the puzzle, the higher the rating the puzzle is given. Ssudoku deliberatley solves puzzles in the same ways as a human would do (but much quicker) in order to give these ratings.

The puzzle ratings are EASY (easiest!), AVERAGE, DIFFICULT, and CHALLENGE (most difficult).

If Ssudoku can't solve a puzzle it is probably because there isn't a single unique answer to the puzzle - that is the person setting it made a mistake. Ssudoku will print out a partly filled in square so you can see how far it got.

Using Ssudoku to Generate Puzzles

Ssudoku has a puzzle generation mode, but it's fair to say that it's still at a fairly experimental stage. It's pretty good at generating AVERAGE difficulty 3x3 puzzles (the default), and also EASY 3x3 puzzles. But more difficult puzzles can take a long time (several minutes to find). The only compensation is that however slow it may be at generating difficult puzzles, it's probably faster than you are at solving them!

If you ask for a 2x2 puzzle, it will always generate an EASY one, as there don't seem to be any 2x2 puzzles that aren't easy!

For 4x4 and 5x5 you can generate EASY or AVERAGE, but generation is pretty slow. Generating more difficult puzzles is theoretically possible, but could take a very, very long time...

OK, enough of the caveats, time to explain how you actually generate a puzzle. Actually it's pretty easy, as all you have to do is run ssudoku without a file name. By default if will generate an AVERAGE, 3x3 puzzle, but you can vary that with the following parameters:

-2Generate a 2x2 puzzle
-3Generate a 3x3 puzzle
-4Generate a 4x4 puzzle
-5Generate a 5x5 puzzle

-e--easyGenerate an easy (least difficult) puzzle
-a--averageGenerate an average difficulty puzzle
-d--difficultGenerate a difficult puzzle
-c--challengeGenerate a challenging (most difficult) puzzle


Copyright © 2005 Mike Moreton