Problem 6 Solution - Ruby