Problem 28 in Ruby.