Add solution to problem 016 in ruby