Solution with Javascript
\n\n/**\n * @param {number} n\n * @return {number}\n */\nvar reinitializePermutation = function(n) {\n    let arr = Array.from({ length: n }, (value, idx) => id
\n```\n/**\n * @param {number} n\n * @return {number}\n */\nvar reinitializePermutation = function(n) {\n    let arr = Array.from({ length: n }, (value, idx) => idx);\n    let count = 0, done = false;\n    while (!done) {\n        const newArr = new Array(n);\n        for (let i = 0; i < arr.length; i++) {\n            if (i % 2) newArr[i] = arr[n / 2 + (i-1) / 2];\n            else newArr[i] = arr[i / 2]\n        }\n        arr = newArr;\n        count++;\n        done = arr.every((value, idx) => value === idx);\n    }\n    return count;\n};\n```
['JavaScript']