some python algorithms