This is from one of my attempts to write a SudokuExplainer clone, the project was to explore how to implement a SudokuExplainer clone in C. This was done, and further developement has now stopped. I'm busy with other stuff.
I've added a simple(!) sudoku generator, tidied the code a bit, and released all under version 3 of the GNU General Public License (GPLv3):
"This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version."
"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details."
If you do not agree with the terms of the GPLv3 license: https://www.gnu.org/licenses/, please do not download this program.
The program (seclone.exe) generates, solves and rates (a single) sudoku that needs singles only to solve. The singles solving code is converted from SudokuExplainer. Sudokus requiring other (not implemented) solving techniques are given a rating of 0.0.
The code has bits I've borrowed from elsewhere, but it's mostly my own. It's coded for speed(!), using global variables (no parameters in function calls) and similar code are repeated (no function calls). There are numerous areas where the code can be improved. As with free software, there is no support!
Some usage information is provided below (this is all the documentation!):
To generate a sudoku [-g generate option]:
- Code: Select all
seclone.exe -g
To generate a sudoku, redirecting the output to a file (puzzle.txt):
- Code: Select all
seclone.exe -g > puzzle.txt
Example puzzle.txt:
- Code: Select all
7..1.2...3..6.74....9.......85........6.1..7........8..5....2...3.5........84.61.
ED=2.3/1.2/1.2
To solve/rate a sudoku [no option specified]:
- Code: Select all
seclone.exe 7..1.2...3..6.74....9.......85........6.1..7........8..5....2...3.5........84.61.
- Code: Select all
seclone.exe puzzle.txt
Example output:
- Code: Select all
748152369312697458569384721285739146496218573173465982851976234634521897927843615
ED=2.3/1.2/1.2
To solve a sudoku (with hints output) [-s solve option]:
- Code: Select all
seclone.exe -s 7..1.2...3..6.74....9.......85........6.1..7........8..5....2...3.5........84.61.
- Code: Select all
seclone.exe -s puzzle.txt
Example output:
Hidden Text: Show
The solution is 'exactly' as SudokuExplainer's solution, as verifed using the hints produced by SukakuExplainer from here: http://forum.enjoysudoku.com/help-with-sudoku-explainer-t6677-60.html#p271963.
To solve a sudoku (with pencilmarks output) [-v verbose option]:
- Code: Select all
seclone.exe -v 7..1.2...3..6.74....9.......85........6.1..7........8..5....2...3.5........84.61.
- Code: Select all
seclone.exe -v puzzle.txt
The output is best redirected to a file for viewing!
The code compiles with TCC (Tiny C Compiler: https://bellard.org/tcc/), using tcc version 0.92.27 downloaded from github: https://github.com/TinyCC/tinycc/releases.
To build seclone.exe:
- Code: Select all
tcc seclone.c
ATTACHMENTS
seclone.zip (7,173 bytes)
seclone_src.zip (26,438 bytes)