Problem twenty five in Ruby