Implementation of various algorithms in ruby