Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Created October 6, 2010 21:09
Show Gist options
  • Save invisiblefunnel/614094 to your computer and use it in GitHub Desktop.
Save invisiblefunnel/614094 to your computer and use it in GitHub Desktop.
Sends an unsolved sudoku puzzle to the sudokuwiki.org solver and scrapes the answer.
# Assign an unsolved sudoku to the string my_puzz. Blanks must be represented by 0's.
my_puzz = '046000000050001000203590040000000900700000300000804710020068100500000072000902000'
# cURL the sudokuwiki.org solver with the given sudoku
system 'curl -o solved.txt --url http://www.sudokuwiki.org/S/WebSudoku.dll?solutions\&0,' + my_puzz + ' >/dev/null 2>&1'
# The solved puzzle is pulled from the 6th line of the returned file.
puts File.open("solved.txt").readlines[6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment