Looking for a Sudoku Algorithm to implement in Ruby

V

Victor Reyes

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hey,

Did anyone know of a Sudoku algorithm, which I can use to implement a Ruby
solution?
Although I can solve Sudoku without much difficulty, I can't say the same
when I try to write a Ruby program to solve Soduku.

Thanks,

Victor
 
K

kevin cline

Hey,

Did anyone know of a Sudoku algorithm, which I can use to implement a Ruby
solution?

The Soduku puzzle can be solved in a few seconds by a very simple
backtracking algorithm:

current_cell = first_empty_cell

while true
if put_next_possible_number_in_current_cell
if all_cells_filled
print_solution
exit
else
current_cell = next_empty_cell
end
else if current_cell = first_empty_cell
raise Exception.new("no solution")
else
current_cell = previous_empty_cell
end
 
V

Victor Reyes

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Thanks to everyone for your suggestions and recommendations.
I truly appreciate all your input.

Thanks again,

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top