def pick_random_char(counts_hash)
      return nil if counts_hash.nil?
      total = counts_hash.values.sum
      pick_num = SecureRandom.rand(total)
      counter = 0
      counts_hash.each do |char, count|
        counter += count
        return char if counter >= pick_num
      end
    end
def pick_random_char(counts_hash)
      return nil if counts_hash.nil?
      total = counts_hash.values.sum
      pick_num = SecureRandom.rand(total)
      counter = 0
      counts_hash.each do |char, count|
        counter += count
        return char if counter >= pick_num
      end
    end
Given a hash in the format: {"c" => {"a" => 1, "b" => 2}}, grab a random
 element from the values hash, accurate to the distribution of counts.
 In the example hash above, "a" would have a 33% chance of being chosen,
 while "b" would have a 66% chance (1/2 ratio).