Realized leap frogs puzzle in python