problem 20 in ruby