Codility in Ruby