examples/mapcolor.rb
# a deterministic check, for comparison purposes
a deterministic check, for comparison purposes
a deterministic check for comparison purposes
def check map, colorized
  map.each do |country, neighbors|
    color = colorized[country]
    neighbors.each do |neighbor|
      if colorized[neighbor] == color
        raise "country #{country} and neighbor #{neighbor} have the same color!"
      end
    end
  end
end
def check map , colorized map . each do | country , neighbors | color = colorized [ country ] neighbors . each do | neighbor | if colorized [ neighbor ] == color raise "country #{country} and neighbor #{neighbor} have the same color!" end end end end
a deterministic check, for comparison purposes
a deterministic check for comparison purposes
map
<not_specific>
colorized
<not_specific>