simple algorithm implement by python