problem 11
problem 11 solution ruby