Basic Algorithms written in Ruby