Clean Python 3, Simulation with only one digit
Here we only trace the move to digit 1.\nCount the moves until it go back to position 1.\n\nTime: O(N)\nSpace: O(1)\n\nclass Solution:\n    def reinitializePerm
Here we only trace the move to digit `1`.\nCount the moves until it go back to position 1.\n\nTime: `O(N)`\nSpace: `O(1)`\n```\nclass Solution:\n    def reinitializePermutation(self, n: int) -> int:\n        if n == 2: return 1\n        half = n // 2\n        curr, ans = 1, 0\n        while True:\n            if curr < half:\n                curr *= 2\n            else:\n                curr -= half\n                curr = 1 + 2 * curr\n            ans += 1\n            if curr == 1: break\n        return ans\n```
[]