{"ScriptPreparationCode":"const tests = [\r\n [0, \u0027\u0027],\r\n [1, \u00276-3\u0027],\r\n [2, \u00271-2,1-2\u0027],\r\n [4, \u00271-1,3-5,5-2,2-3,2-4\u0027],\r\n [8, \u00272-3,2-1,1-4,4-4,4-4,5-4,4-2,2-1\u0027],\r\n [5, \u00272-3,2-1,1-4,3-3,3-4,5-4,4-2,2-1\u0027],\r\n [4, \u00273-5,2-1,1-4,4-4,4-4,5-3,3-2,2-1\u0027],\r\n [7, \u00273-2,2-1,1-4,4-4,4-4,4-3,3-2,4-5,3-5,2-1,1-4,2-2,4-4,5-3,3-2,2-1\u0027],\r\n];\r\n\r\nfunction run(fn) {\r\n tests.forEach(([result, input], i) =\u003E {\r\n const res = fn(input);\r\n\r\n console.log(\u0060Test ${1}: \u0027${input}\u0027\u0060);\r\n console.log(\u0060Expected: ${result} - ${res === result}\u0060);\r\n console.log(res);\r\n console.log(\u0027=============================\u0027);\r\n });\r\n}","TestCases":[{"Name":"Alex","Code":"const domino = (dominoQueue) =\u003E {\r\n const splitQueue = dominoQueue.split(\u0022,\u0022).map((item) =\u003E {\r\n return item.split(\u0022-\u0022);\r\n });\r\n\r\n let countsArr = [0];\r\n\r\n for (let i = 0; i \u003C splitQueue.length; i\u002B\u002B) {\r\n const currentQueueItemArray = splitQueue[i];\r\n const nextQueueItemArray = splitQueue[i \u002B 1];\r\n\r\n if (Array.isArray(nextQueueItemArray)) {\r\n if (currentQueueItemArray[1] === nextQueueItemArray[0]) {\r\n countsArr[countsArr.length - 1] \u002B= 1;\r\n } else {\r\n countsArr[countsArr.length] = 0;\r\n }\r\n }\r\n }\r\n\r\n return Math.max(...countsArr);\r\n};\r\n\r\nrun(domino);","IsDeferred":false},{"Name":"Nik","Code":"function domino(dominoes) {\r\n\tlet chains = [0];\r\n\r\n\tif (dominoes) {\r\n\t\tconst chain = dominoes.split(\u0027,\u0027);\r\n\r\n\t\tlet prev = [];\r\n\t\tlet chainI = 0;\r\n\t\tchain.forEach((item, i) =\u003E {\r\n\t\t\tconst current = item.split(\u0027-\u0027);\r\n\r\n\t\t\tif (!i || (prev.length \u0026\u0026 prev.some((v) =\u003E current.includes(v)))) {\r\n\t\t\t\tchains[chainI]\u002B\u002B;\r\n\t\t\t} else {\r\n\t\t\t\tchainI\u002B\u002B;\r\n\t\t\t\tchains[chainI] = 1;\r\n\t\t\t}\r\n\r\n\t\t\tprev = current;\r\n\t\t});\r\n\t}\r\n\r\n\treturn chains.sort((a, b) =\u003E b - a)[0];\r\n}\r\n\r\nrun(domino);","IsDeferred":false}]}