ruby solution to problem 25