Commits

shl...@27f4d2be-69b7-b1af-7dc8-71755b09f50e  committed e2a13d9

Fix a bug with an error upon three in a row. (With a test).

Now can solve http://www.menneske.no/hitori/5x5/eng/showpuzzle.html?number=2 .

  • Participants
  • Parent commits 6a2c77c

Comments (0)

Files changed (2)

File hitori-solver-in-ruby/hitori-solver.rb

 
             elsif (sorted_seqs[0].length() == 3) then
 
-                if (sorted_seqs[1].length() >= 2) then
+                if sorted_seqs.length > 1 and sorted_seqs[1].length() >= 2
                     raise TwoPairsException, \
                         "Found two pairs in #{dir} #{row}"
                 else

File hitori-solver-in-ruby/t/parse-board.rb

 
 end
 
+describe "Process for Board No. 2" do
+
+    before (:each) do
+
+        params = HitoriSolver::Board.parse(
+            File.read("./boards/menneske.no-2.txt")
+        )
+
+        @board = HitoriSolver::Board.new(*params)
+
+        @process = HitoriSolver::Process.new(@board)
+    end
+
+    it "should not die upon analyze_sequences" do
+        # http://www.menneske.no/hitori/5x5/eng/showpuzzle.html?number=1
+        #
+        board = @board
+        process = @process
+
+        process.analyze_sequences()
+
+        # Reached here successfully .
+        1.should == 1
+    end
+end