Solve challenge 3 in Ruby