sudokude 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sudokude.rb +13 -13
- metadata +2 -2
data/lib/sudokude.rb
CHANGED
@@ -36,7 +36,7 @@ module Sudokude
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def print
|
39
|
-
|
39
|
+
self.each do |row|
|
40
40
|
row.map! do |e|
|
41
41
|
if e.nil?
|
42
42
|
"n"
|
@@ -97,25 +97,25 @@ module Sudokude
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
return @sudoku.values.each_slice(9).to_a
|
101
101
|
|
102
102
|
end
|
103
103
|
|
104
104
|
private
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
# Array#compact removes all nils. A solved puzzle has no nils to remove.
|
107
|
+
def solved
|
108
|
+
@sudoku.values.compact.size == 81
|
109
|
+
end
|
110
110
|
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
112
|
+
# This evaluates the number of solved keys in the puzzle. If no new blanks have been
|
113
|
+
# filled in over multiple passes through the solving methods, then the puzzle cannot
|
114
|
+
# be solved.
|
115
|
+
def unsolvable
|
116
|
+
@keysizes << @sudoku.values.compact.size
|
117
|
+
@keysizes[-1] == @keysizes[-3]
|
118
|
+
end
|
119
119
|
|
120
120
|
end
|
121
121
|
|