# Commits

committed 5cd67e3

Implement the all_coords instead of coords_loop

• Participants
• Parent commits 58507db
• Branches default

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

• Ignore whitespace
`             return @y_len-1`
`         end`
` `
`-        def coords_loop`
`-            for y in (0 .. maxy()) do`
`-                for x in (0 .. maxx()) do`
`-                    yield [y,x]`
`+        class Coords_Loop`
`+            include Enumerable`
`+`
`+            def initialize(maxy, maxx) `
`+                @maxy = maxy`
`+                @maxx = maxx`
`+            end`
`+`
`+            def each`
`+                ( 0 .. @maxy ).each do |y|`
`+                    ( 0 .. @maxx ).each do |x|`
`+                        yield [y,x]`
`+                    end`
`                 end`
`             end`
`         end`
` `
`+        def all_coords`
`+            return Coords_Loop.new(maxy(), maxx())`
`+        end`
`+`
`         def loop_over_whites`
`-            coords_loop do |yx|`
`+            all_coords.each do |yx|`
`                 if cell_yx(yx).is_white() then`
`                     yield yx`
`                 end`
`             end`
` `
`             def _calc_adjacent(board)`
`-                board.coords_loop do |yx|`
`+                board.all_coords.each do |yx|`
`                     # TODO : Write better. The loop with assignment `
`                     # is ugly.`
`                     is_adj = false`
`             counter[DIR_X] = (0 .. @board.maxx).map { |x| Hash.new }`
`             counter[DIR_Y] = (0 .. @board.maxy).map { |y| Hash.new }`
` `
`-            @board.coords_loop do |yx|`
`+            @board.all_coords.each do |yx|`
`                 val = @board.cell(0, yx).value`
` `
`                 counter.set_val(yx, val)`