Solve problem 74 using Ruby.