completed problem 1 with ruby.