I've modified rjamil's 'Bitwise/Boolean Sudoku Solver' to solve a single sudoku, by replacing the program main() function with this:
Hidden Text: Show
I've renamed my modified program RJBitSolve.c
In Windows with Visual Studio, I compile with this command: cl.exe /TpRJBitSolve.c
Run the modified program, passing it either: 1) a sudoku string (of 81 characters) as argument,
- Code: Select all
RJBitSolve.exe ..5..2..9.83....7.4.987.1.......5.6...7.8.2...3.4.......8.247.3.7....95.3..7..8..
or 2) a filename containing a sudoku (only the first 81 characters are read),
- Code: Select all
RJBitSolve.exe test.sud
The program displays the sudoku solution:
- Code: Select all
..5..2..9.83....7.4.987.1.......5.6...7.8.2...3.4.......8.247.3.7....95.3..7..8..
715342689683591472429876135894215367567983241132467598958624713276138954341759826
# C:29 # N:5 # H:47 # G:0 # D:0 # T:0.000000
The last line of stats give details:
# C: number of givens
# N: number of naked singles solved
# H: number of hidden singles solved
# G: number of guesses
# D: maximum guess and depth
# T: time in seconds to solve!
I also have RJBitSolve3.c (with #define RJ 3) and RJBitSolve4.c (with #define RJ 4) compiled and ready to print the solving steps and pencil marks, if these are needed... RJ 1 and 2 are no longer available as they were used in the old main() function.
The program has a 50% success rate with solving the last few recent sudokus posted in the Puzzles section:
Historical Daily 22 - SOLVED
- Code: Select all
4.....82...3...1.958....3.4..7.2........76.9..68.....1...7.563.....1.54....3..9.8
479163825623458179581297364397521486145876293268934751914785632832619547756342918
# C:28 # N:2 # H:51 # G:0 # D:0 # T:0.000000
May 25, 2018 - 2 GUESSES
- Code: Select all
2....97......1..6....4....3....7..2...83.65...4..8....9....2....6..5......38....1
215639748834715962679428153391574826728396514546281379987142635162953487453867291
# C:22 # N:1 # H:66 # G:2 # D:1 # T:0.000000
Historical Daily 23 - 4 GUESSES
- Code: Select all
.19.2..83.538.1.29.28..351..6...219...21....5.41.59.62.......3..349.8.56.86.3.9..
419527683753861429628493517365742198972186345841359762297615834134978256586234971
# C:40 # N:0 # H:58 # G:4 # D:3 # T:0.000000
Historical Daily 24 - SOLVED
- Code: Select all
.3.....8...79826..6.......737.2.......1.78..2..86...9.7...9.1...6.1.48......2..36
235761489147982653689345217376219548591478362428653791753896124962134875814527936
# C:29 # N:0 # H:52 # G:0 # D:0 # T:0.000000
Enjoy!
ATTACHMENT:
RJBitSolve.c (169.3 KiB), download link: RJBitSolve.c.zip (23,574 bytes)