Ruby version of problem 1 (why not)