Common algorithms implemented in ruby