Some basic algorithms written in ruby