Algorithms implemented in ruby