working on python algorithms