Adding Ruby solution to problem 3