Solve problems 4,97 using Ruby.