Common algorithms implemented in Ruby