Algorithms implemented by Ruby