problem 2 ruby solution