common algorithms in ruby