Skip to content
Browse files

slight refactoring to match Norvig's fn names

  • Loading branch information...
1 parent e70aaa2 commit 545c1e03eef5c64ccee4508eb651ba65343254ba @bitsai committed Oct 20, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 sudoku.rb
View
8 sudoku.rb
@@ -81,7 +81,7 @@ def eliminate(values, s, d)
return values
end
-def print_board(values)
+def display(values)
max_size = $squares.map{ |s| values[s].size }.max + 1
line = (["-" * max_size * 3] * 3).join("+")
@@ -105,7 +105,11 @@ def search(values)
return some(values[s].map{ |d| search(assign(deep_copy(values), s, d)) })
end
+def solve(grid)
+ return search(parse_grid(grid))
+end
+
# Main
file = ARGV[0]
grid_str = File.read(file).gsub(/\n/, "")
-print_board(search(parse_grid(grid_str)))
+display(solve(grid_str))

0 comments on commit 545c1e0

Please sign in to comment.
Something went wrong with that request. Please try again.