solved problem 4 - ruby practice