Problem 18 in Ruby.
Problem 18 in Ruby.