various common algorithms implemented in ruby