solved problem 20 in ruby. ruby is awesome.