Choose a color with probability proportionate to its weight in a group of colors
I can't think of a better algorithm.  There is a minor bug, though: you are using inclusive-inclusive ranges, when they should be inclusive-exclusive ranges.  That means that you've overweighted red by \$\frac{1}{60}\$ and underweighted green by \$\frac{1}{60}\$.

The way it the algorithm is expressed could be tweaked a bit.


The count isn't counting elements; it's more of a sum.
The block could accept two parameters |color, weight| to automatically destructure |color_weight|.
The hash isn't really being used for a lookup, so I would just keep it as an array.




def random_color(colors_with_weights)
  sum = 0
  colors_with_cumul_weights = colors_with_weights.collect do |color, weight|
    [color, sum ... (sum += weight)]
  end
  rand_num = rand(sum)
  colors_with_cumul_weights.find { |color, range| range === rand_num }.first
end


In an interview situation, I'd just accept your code as a fine answer.