{"ScriptPreparationCode":"function trimAsterisks(data) {\r\n return data.reduce(\r\n ({ state, output }, val) =\u003E\r\n val == \u0027*\u0027\r\n ? { state: \u0027*\u0027, output }\r\n : { state: \u0027\u0027, output: output.concat(state \u002B val) },\r\n { state: \u0027\u0027, output: [] }\r\n ).output;\r\n}\r\n\r\nfunction collapse(array) {\r\n const result = [];\r\n\r\n for (const [i, n] of array.entries()) {\r\n if (n !== \u0027*\u0027) {\r\n result.push(array[i - 1] === \u0027*\u0027 ? \u0060*${n}\u0060 : n);\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction collapseReduce(array) {\r\n return array.reduce((a, n, i, { [i - 1]: prev }) =\u003E {\r\n if (n !== \u0027*\u0027) {\r\n a.push(prev === \u0027*\u0027 ? \u0060*${n}\u0060 : n);\r\n }\r\n return a;\r\n }, []);\r\n}\r\n\r\nvar data = [\r\n \u00270\u0027,\r\n \u00271\u0027,\r\n \u00272\u0027,\r\n \u00273\u0027,\r\n \u00274\u0027,\r\n \u00275\u0027,\r\n \u00276\u0027,\r\n \u0027*\u0027,\r\n \u0027*\u0027,\r\n \u00279\u0027,\r\n \u002710\u0027,\r\n \u002711\u0027,\r\n \u002712\u0027,\r\n \u002713\u0027,\r\n \u002714\u0027,\r\n \u002715\u0027,\r\n \u002716\u0027,\r\n \u002717\u0027,\r\n \u002718\u0027,\r\n \u002719\u0027,\r\n \u002720\u0027,\r\n \u002721\u0027,\r\n \u002722\u0027,\r\n \u002723\u0027,\r\n \u002724\u0027,\r\n \u002725\u0027,\r\n \u002726\u0027,\r\n \u002727\u0027,\r\n \u002728\u0027,\r\n \u002729\u0027,\r\n \u002730\u0027,\r\n \u002731\u0027,\r\n \u002732\u0027,\r\n \u0027*\u0027,\r\n \u002734\u0027,\r\n \u0027*\u0027,\r\n \u002736\u0027,\r\n \u002737\u0027,\r\n \u0027*\u0027,\r\n \u002739\u0027,\r\n \u002740\u0027,\r\n \u002741\u0027,\r\n \u002742\u0027,\r\n \u002743\u0027,\r\n \u002744\u0027,\r\n \u002745\u0027,\r\n \u002746\u0027,\r\n \u002747\u0027,\r\n \u002748\u0027,\r\n \u002749\u0027,\r\n \u002750\u0027,\r\n \u002751\u0027,\r\n \u002752\u0027,\r\n \u0027*\u0027,\r\n \u002754\u0027,\r\n \u0027*\u0027,\r\n \u002756\u0027,\r\n \u002757\u0027,\r\n \u002758\u0027,\r\n \u002759\u0027,\r\n \u002760\u0027,\r\n \u002761\u0027,\r\n \u002762\u0027,\r\n \u002763\u0027,\r\n \u002764\u0027,\r\n \u002765\u0027,\r\n \u002766\u0027,\r\n \u002767\u0027,\r\n \u002768\u0027,\r\n \u002769\u0027,\r\n \u002770\u0027,\r\n \u002771\u0027,\r\n \u002772\u0027,\r\n \u002773\u0027,\r\n \u0027*\u0027,\r\n \u0027*\u0027,\r\n \u0027*\u0027,\r\n \u0027*\u0027,\r\n \u002778\u0027,\r\n \u002779\u0027,\r\n \u002780\u0027,\r\n \u002781\u0027,\r\n \u002782\u0027,\r\n \u002783\u0027,\r\n \u002784\u0027,\r\n \u002785\u0027,\r\n \u002786\u0027,\r\n \u002787\u0027,\r\n \u002788\u0027,\r\n \u002789\u0027,\r\n \u0027*\u0027,\r\n \u002791\u0027,\r\n \u002792\u0027,\r\n \u002793\u0027,\r\n \u002794\u0027,\r\n \u002795\u0027,\r\n \u0027*\u0027,\r\n \u002797\u0027,\r\n \u0027*\u0027,\r\n \u0027*\u0027,\r\n];\r\n","TestCases":[{"Name":"State machine","Code":"const result = trimAsterisks(data);","IsDeferred":false},{"Name":"Simple loop","Code":"const result = collapse(data);","IsDeferred":false},{"Name":"Simple loop (reduce)","Code":"const result = collapseReduce(data);","IsDeferred":false}]}