{"ScriptPreparationCode":"function getRandomInt(max) {\r\n return Math.floor(Math.random() * max);\r\n}\r\n\r\nfunction getLargeNumber(nl)\r\n{\r\n let number = getRandomInt(9999999999999999) \u002B \u0027\u0027; // we\u0027ll keep the digits as a string, and make it into a string so we can just keep adding numbers to it to make it longer\r\n \r\n while(number.length \u003C= nl)\r\n {\r\n number \u002B= getRandomInt(9999999999999999);\r\n }\r\n \r\n return number.substring(0, nl);\r\n}","TestCases":[{"Name":"Intuitive","Code":"const nl = 50000;\r\nconst number = getLargeNumber(nl);\r\nconst gpl = 10;\r\nlet greatestProduct = 0\r\nlet greatestProductPosition = 0;\r\n\r\nfor(i = 0; i \u003C nl-gpl; i\u002B\u002B)\r\n{\r\n currentProduct = 1;\r\n \r\n for(j = i; j \u003C i\u002Bgpl; j\u002B\u002B)\r\n {\r\n currentProduct *= parseInt(number[j]);\r\n }\r\n \r\n if(currentProduct \u003E greatestProduct)\r\n {\r\n greatestProduct = currentProduct;\r\n greatestProductPosition = i;\r\n }\r\n}","IsDeferred":false},{"Name":"Fast","Code":"const nl = 50000;\r\nconst number = getLargeNumber(nl);\r\nconst gpl = 10;\r\nlet greatestProduct = 0\r\nlet greatestProductPosition = 0;\r\n\r\nfor(i = 0; i \u003C nl; i\u002B\u002B)\r\n{\r\n if(i \u003E= gpl)\r\n {\r\n if(parseInt(number[i-gpl]) \u003E 0)\r\n {\r\n if(currentProduct \u003E 0)\r\n {\r\n currentProduct /= parseInt(number[i-gpl]);\r\n }\r\n }\r\n else\r\n {\r\n currentProduct = 1;\r\n \r\n for(j = i-(gpl-1); j \u003C i; j\u002B\u002B)\r\n {\r\n if(parseInt[j] \u003E 0)\r\n {\r\n currentProduct *= parseInt(number[j]);\r\n }\r\n else\r\n {\r\n currentProduct = 0;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n \r\n currentProduct *= parseInt(number[i]);\r\n \r\n if(i \u003E= (gpl-1) \u0026\u0026 currentProduct \u003E greatestProduct)\r\n {\r\n greatestProduct = currentProduct;\r\n greatestProductPosition = i - (gpl-1);\r\n }\r\n}","IsDeferred":false},{"Name":"Array","Code":"const nl = 50000;\r\nconst number = getLargeNumber(nl);\r\nlet split = [];\r\nconst gpl = 10;\r\nlet greatestProduct = 0\r\nlet greatestProductPosition = 0;\r\nlet lastPos = 0;\r\n\r\nwhile((newPos = number.indexOf(\u00270\u0027, lastPos)) !== -1)\r\n{\r\n if(newPos - lastPos \u003E 0)\r\n {\r\n split.push([lastPos, newPos - lastPos]);\r\n }\r\n\r\n lastPos = newPos \u002B 1;\r\n}\r\n\r\nif(nl - lastPos \u003E 0)\r\n{\r\n split.push([lastPos, nl - lastPos]);\r\n}\r\n\r\nsplit.forEach(([start, length]) =\u003E\r\n{\r\n if(length \u003C gpl) return;\r\n \r\n currentProduct = 1;\r\n \r\n for(i = start; i \u003C (start \u002B length); i\u002B\u002B)\r\n {\r\n if(i \u003E= (gpl \u002B start))\r\n {\r\n currentProduct /= parseInt(number[i-gpl]);\r\n }\r\n \r\n currentProduct *= parseInt(number[i]);\r\n \r\n if(i \u003E= (gpl \u002B start - 1) \u0026\u0026 currentProduct \u003E greatestProduct)\r\n {\r\n greatestProduct = currentProduct;\r\n }\r\n }\r\n});","IsDeferred":false}]}