In 1st puzzle I used: start_cubes = {red: 12, green: 13, blue: 14} start_cubes.default = 0 def possible_play? start_cubes, taken_cubes taken_cubes.each{|color,number| return false if start_cubes[color] < number } true end ... I set default of hash because I was thinking: is it possible that in some games (or in 2nd puzzle) they will try to pick up a cube of some other color.
In 1st puzzle I used:
start_cubes = {red: 12, green: 13, blue: 14}
start_cubes.default = 0
def possible_play? start_cubes, taken_cubes
taken_cubes.each{|color,number|
return false if start_cubes[color] < number
}
true
end
...
I set default of hash because I was thinking: is it possible that in some games (or in 2nd puzzle) they will try to pick up a cube of some other color.
Nice move with default