did the ruby version of problem 4