Added problem 3 in ruby