Problem 6 is completed in Ruby