Solves Sudoku puzzles. It uses similar techniques to ones a human would use so the complexity rating is accurate.
Enter ruby jSudoku 1 to solve puzzle number 1. There are 15 puzzles.
The board is evaluated once and then it is printed out. If a cell has been solved, the solution is placed bottom center in the cell. Otherwise a "?" is printed and the possible values for the cell are printed above it.
######################################################################### # | 4 | 3 # 34 | | # | 34 | 4 # # | 6 8 | 8 # 67 | | # | 8 | 7 # # 9 | ? | ? # ? | 5 | 2 # 1 | ? | ? # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | 12 4 | 123 # 34 | 1 3 | 1 3 # 23 5 | 2345 | 2 45 # # | 6 8 | 8 # 6 9 | | 6 9 # 8 | 89 | 9 # # 7 | ? | ? # ? | ? | ? # ? | ? | ? # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # 1 34 | 12 4 | # 34 | | 1 3 # 23 | 234 | # # | | # 7 9 | | 7 9 # 7 | 9 | # # ? | ? | 5 # ? | 8 | ? # ? | ? | 6 # ######################################################################### # | 12 5 | 12 # 3 5 | 23 | # | 123 5 | 2 5 # # | 67 | 7 # 67 | 7 | # | 6 | # # 8 | ? | ? # ? | ? | 4 # 9 | ? | ? # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # 1 5 | | 12 # 5 | | 5 # 2 5 | | 2 45 # # 6 | | # 6 8 | | 6 8 # 6 | | # # ? | 3 | ? # ? | 9 | ? # ? | 7 | ? # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # 5 | 2 5 | # | 23 | 3 5 # 23 5 | 23 5 | # # 6 | 67 9 | # | 7 | 67 # 6 | 6 | # # ? | ? | 4 # 1 | ? | ? # ? | ? | 8 # ######################################################################### # | 1 5 | 1 3 # 3 5 | | 1 3 5 # | 5 | 5 # # | 789 | 789 # 789 | | 789 # | 89 | 7 9 # # 2 | ? | ? # ? | 6 | ? # 4 | ? | ? # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # 1 45 | 1 45 | 1 # 5 | 1 | 1 5 # 2 5 | 2 5 | # # | 789 | 789 # 789 | 7 | 789 # 678 | 6 89 | # # ? | ? | ? # ? | ? | ? # ? | ? | 3 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # 3 5 | 5 | # | | 3 5 # 5 | 5 | # # | 789 | # | | 789 # 78 | 89 | # # ? | ? | 6 # 2 | 4 | ? # ? | ? | 1 # #########################################################################
There will then be a series of lines indicating an going complexity calculation and the characteristics of the puzzle that are contributing to the complexity.
Unique - row : 5 7 Singleton - row : 1 10 Unique - col : 5 18 Subrow - row : 20 42 Subcol - col : 20 67 Unique - row : 5 78 Unique - row : 5 90 Singleton - row : 1 99 Singleton - row : 1 109 Unique - row : 5 124 Unique - row : 5 140 Unique - col : 5 157 Subrow - row : 20 190 HiddenPair- blk : 40 244 Unique - col : 5 264 Unique - row : 5 285 Unique - col : 5 307 Singleton - row : 1 326 Singleton - row : 1 346 Singleton - row : 1 367 Singleton - row : 1 389 Singleton - row : 1 412 Singleton - row : 1 436
And finally, the solved puzzle is presented and the complexity rating is displayed.
A check is made to verify that the solved puzzle does have values 1-9 in rows, columns and blocks. If everything checks out, "Verified" is printed.
######################################################################### # | | # | | # | | # # | | # | | # | | # # 9 | 6 | 8 # 3 | 5 | 2 # 1 | 4 | 7 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | | # | | # | | # # | | # | | # | | # # 7 | 2 | 3 # 4 | 1 | 6 # 8 | 5 | 9 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | | # | | # | | # # | | # | | # | | # # 4 | 1 | 5 # 7 | 8 | 9 # 3 | 2 | 6 # ######################################################################### # | | # | | # | | # # | | # | | # | | # # 8 | 5 | 7 # 6 | 3 | 4 # 9 | 1 | 2 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | | # | | # | | # # | | # | | # | | # # 1 | 3 | 2 # 5 | 9 | 8 # 6 | 7 | 4 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | | # | | # | | # # | | # | | # | | # # 6 | 9 | 4 # 1 | 2 | 7 # 5 | 3 | 8 # ######################################################################### # | | # | | # | | # # | | # | | # | | # # 2 | 7 | 1 # 9 | 6 | 3 # 4 | 8 | 5 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | | # | | # | | # # | | # | | # | | # # 5 | 4 | 9 # 8 | 7 | 1 # 2 | 6 | 3 # #-------+-------+-------#-------+-------+-------#-------+-------+-------# # | | # | | # | | # # | | # | | # | | # # 3 | 8 | 6 # 2 | 4 | 5 # 7 | 9 | 1 # ######################################################################### Complexity: 436 Verified
| Contact me about content on this page using john_web-at-arrizza-dot-com |
| For Web Master or site problems contact: webadmin-at-arrizza-dot-com |
| Copyright John Arrizza (c) 2001-2010 |