tortoise and hare algorithm python