Algorithms in Ruby