ruby solution to problem 2 added