Created
September 9, 2011 02:32
-
-
Save mark-d-holmberg/1205363 to your computer and use it in GitHub Desktop.
How to generate Sudoku boards for the Solver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mark Holmberg, Dixie State College of Utah | |
# CS 3520, Programming Languages | |
# 8 Sept. 2011 | |
# http://www.sudoku-solutions.com/ | |
# Purpose: Generate 'unsolved' sudoku puzzles for the sudoku | |
# solver to solve. | |
# Step One: Go to the URL above and hit the 'Random' button. | |
# Step Two: After the board is formed hit the 'Save' button and open the | |
# .csv file into your favorite editor and copy the string they give you. | |
# The next step requires that you have ruby installed on your system, if you don't | |
# you'll need to install it first. | |
# Step Three: open irb1.8 in a terminal by typing 'irb1.8' at the prompt | |
# Next type: board ="<my random string here>.to_s" | |
# This will tell Ruby that those random characters are a string. | |
#Step Four: Then type: | |
board.split('').join(',').gsub!( /\./, '_' ).insert(0,'[').insert(-1, ']'); | |
# into IRB. You will get a string back like the following | |
#[_,3,_,6,_,_,4,9,_,_,5,_,7,_,4,6,_,_,4,8,_,_,_,9,_,_,_,7,1,_,_,_,_,_,3,_,_,_,3, | |
#_,_,_,2,_,_,_,2,_,_,_,_,_,7,4,8,_,2,_,_,_,_,4,_,_,_,5,9,4,1,7,8,_,_,9,4,_,7,2, | |
#_,_,_] | |
# Step Five: Copy everything from the [ to the ] into your Sudoku prolog solver | |
# sudoku ( [<zomg big string here>], Solution ). | |
# Best of luck! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment