Adding Ruby solution to problem 2