Browse files

Fixed tests after some files names' chanded

  • Loading branch information...
1 parent 971c6bd commit 384b1b45cccb25479d84c638301056d0c302c492 Dave Hoover committed Jan 2, 2009
Showing with 2 additions and 132 deletions.
  1. +0 −130 sudoku/main.rb
  2. +1 −1 sudoku/solver.rb
  3. +1 −1 sudoku/test.rb
View
130 sudoku/main.rb
@@ -1,130 +0,0 @@
-require 'board'
-require 'brain'
-require 'brain_cell'
-require 'core_ext'
-require 'grids'
-require 'ostruct'
-require 'solver'
-
-def think(board, brain, state)
- board = board.deep_copy
- brain = brain.deep_copy
- grids = Grids.new(board)
-
- blanks = board.blanks
- if blanks.empty?
- state.finished = board
- return
- end
-
- return if state.finished
-
- begin
- brain.narrow(blanks, board, grids)
- rescue BrainCell::EmptyException
- return
- end
-
- solvers = brain.solvers(blanks)
-
- if solvers.empty?
- brain.guess(board, blanks, state)
-
- else
- begin
- solvers.check_for_conflicts(grids)
- solvers.solve(board)
- rescue Solver::ConflictException
- return
- end
- end
-
- think(board, brain, state)
-end
-
-# http://en.wikipedia.org/wiki/Sudoku
-wiki = [
-"53 7
-6 195
- 98 6
-8 6 3
-4 8 3 1
-7 2 6
- 6 28
- 419 5
- 8 79",
-
-"534678912
-672195348
-198342567
-859761423
-426853791
-713924856
-961537284
-287419635
-345286179"
-]
-
-# http://www.websudoku.com/?level=2&set_id=3350218628
-medium = [
-" 4 7 3
- 85 1
- 15 3 9
-5 7 21
- 6 8
- 81 6 9
- 2 4 57
- 7 29
- 5 7 8 ",
-
-"942187635
-368594127
-715236498
-593478216
-476921853
-281365749
-829643571
-137852964
-654719382"
-]
-
-# http://www.websudoku.com/?level=4&set_id=470872047
-evil = [
-" 53 694
- 3 1 6
- 3
-7 9
- 1 3 2
- 2 7
- 6
-8 7 5
- 436 81 ",
-
-"285376941
-439125786
-176849235
-752981364
-618734529
-394562817
-567213498
-821497653
-943658172"
-]
-
-[wiki, medium, evil].each do |start, solved|
-
- board = Board.new(start)
- fail("Bad board") unless board.size == 9 && board[4].size == 9
-
- brain = Brain.new
- fail("Bad brain: rows=#{brain.size}, cols=#{brain[7].size}") unless brain.size == 9 && brain[7].size == 9 && brain[3][1].size == 9
-
- state = OpenStruct.new
- think(board, brain, state)
-
- if state.finished == Board.new(solved)
- puts "PASS"
- else
- puts "FAIL\nExpected\n#{Board.new(solved).report}\nBut got\n#{state.finished.report}"
- end
-end
View
2 sudoku/solver.rb
@@ -4,7 +4,7 @@
require 'core_ext'
require 'grids'
require 'ostruct'
-require 'solver'
+require 'solvers'
def solve(start)
board = Board.new(start)
View
2 sudoku/test.rb
@@ -1,4 +1,4 @@
-require 'main'
+require 'solver'
# http://en.wikipedia.org/wiki/Sudoku
wiki = [

0 comments on commit 384b1b4

Please sign in to comment.