{"ScriptPreparationCode":"var arraySmall = new Array(12).map((v,i)=\u003Ei);\r\nvar arrayMedium = new Array(1200).map((v,i)=\u003Ei);\r\nvar arrayLong = new Array(120000).map((v,i)=\u003Ei);\r\n","TestCases":[{"Name":"Recursive Small","Code":"const rotateArrayRecursive = (numberRotations, array) =\u003E {\r\n const n = Math.abs(numberRotations);\r\n if (n === 0) {\r\n return [...array];\r\n } else if (n === 1) {\r\n return [array[array.length], ...array.slice(0,array.length-1) ];\r\n } else {\r\n return rotateArrayRecursive(1, rotateArrayRecursive(n - 1, array));\r\n }\r\n}\r\n\r\nrotateArrayRecursive(4,arraySmall);","IsDeferred":false},{"Name":"Recursive Medium","Code":"const rotateArrayRecursive = (numberRotations, array) =\u003E {\r\n const n = Math.abs(numberRotations);\r\n if (n === 0) {\r\n return [...array];\r\n } else if (n === 1) {\r\n return [array[array.length], ...array.slice(0,array.length-1) ];\r\n } else {\r\n return rotateArrayRecursive(1, rotateArrayRecursive(n - 1, array));\r\n }\r\n}\r\n\r\nrotateArrayRecursive(456,arrayMedium);","IsDeferred":false},{"Name":"Recursive Long","Code":"const rotateArrayRecursive = (numberRotations, array) =\u003E {\r\n const n = Math.abs(numberRotations);\r\n if (n === 0) {\r\n return [...array];\r\n } else if (n === 1) {\r\n return [array[array.length], ...array.slice(0,array.length-1) ];\r\n } else {\r\n return rotateArrayRecursive(1, rotateArrayRecursive(n - 1, array));\r\n }\r\n}\r\n\r\nrotateArrayRecursive(45678,arrayLong);","IsDeferred":false},{"Name":"Direct Small","Code":"const rotateArrayDirect = (desiredRotation, array) =\u003E {\r\n\r\n // Size of the array, needed later on\r\n const arrayLength = array.length;\r\n\r\n // Ensure we rotate by the right amount, whatever the desiredRotation value\r\n // This formula is needed because JS % modulo operator returns negative output for negative inputs\r\n const effectiveRotation = ((desiredRotation % arrayLength) \u002B 2 * arrayLength) % arrayLength;\r\n\r\n // Cut the array in two parts and merge them\r\n return [\r\n ...array.slice(effectiveRotation, arrayLength),\r\n ...array.slice(0, effectiveRotation)\r\n ];\r\n}\r\n\r\nrotateArrayDirect(4,arraySmall);","IsDeferred":false},{"Name":"Direct Medium","Code":"const rotateArrayDirect = (desiredRotation, array) =\u003E {\r\n\r\n // Size of the array, needed later on\r\n const arrayLength = array.length;\r\n\r\n // Ensure we rotate by the right amount, whatever the desiredRotation value\r\n // This formula is needed because JS % modulo operator returns negative output for negative inputs\r\n const effectiveRotation = ((desiredRotation % arrayLength) \u002B 2 * arrayLength) % arrayLength;\r\n\r\n // Cut the array in two parts and merge them\r\n return [\r\n ...array.slice(effectiveRotation, arrayLength),\r\n ...array.slice(0, effectiveRotation)\r\n ];\r\n}\r\n\r\nrotateArrayDirect(456,arrayMedium);","IsDeferred":false},{"Name":"Direct Long","Code":"const rotateArrayDirect = (desiredRotation, array) =\u003E {\r\n\r\n // Size of the array, needed later on\r\n const arrayLength = array.length;\r\n\r\n // Ensure we rotate by the right amount, whatever the desiredRotation value\r\n // This formula is needed because JS % modulo operator returns negative output for negative inputs\r\n const effectiveRotation = ((desiredRotation % arrayLength) \u002B 2 * arrayLength) % arrayLength;\r\n\r\n // Cut the array in two parts and merge them\r\n return [\r\n ...array.slice(effectiveRotation, arrayLength),\r\n ...array.slice(0, effectiveRotation)\r\n ];\r\n}\r\n\r\nrotateArrayDirect(45678,arrayLong);","IsDeferred":false}]}