{"ScriptPreparationCode":"var data = [[\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u00228\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u00225\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u00224\u0022,\u0022.\u0022,\u0022.\u0022,\u00222\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u00223\u0022,\u0022.\u0022,\u00229\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u00221\u0022,\u00228\u0022,\u0022.\u0022,\u0022.\u0022,\u00229\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u00225\u0022,\u00221\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u00223\u0022,\u0022.\u0022,\u0022.\u0022,\u00228\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u00221\u0022,\u00222\u0022,\u0022.\u0022,\u00223\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022], \r\n [\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u0022.\u0022,\u00227\u0022,\u0022.\u0022,\u0022.\u0022,\u00221\u0022]]","TestCases":[{"Name":"shao","Code":"function sudoku2(grid) {\r\n var empty = \u0022.\u0022;\r\n var chunk = [];\r\n \r\n for (var i = 0; i \u003C grid.length; i\u002B\u002B) {\r\n for (var j = 0; j \u003C grid.length; j\u002B\u002B) {\r\n if (j % 3 === 0 \u0026\u0026 !checkChunk(i, j)) {\r\n return false;\r\n }\r\n \r\n if (checkRowValid(grid[i], grid[i][j], j)) {\r\n return false;\r\n }\r\n \r\n if (checkColumnValid(grid, i, j)) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n \r\n function checkChunk(rowIndex, colIndex) {\r\n var counter = rowIndex % 3;\r\n \r\n while (counter \u003C 3 \u0026\u0026 (rowIndex \u002B counter) \u003C grid.length) {\r\n chunk.push(grid[rowIndex \u002B counter].slice(colIndex, colIndex \u002B 3));\r\n counter\u002B\u002B;\r\n }\r\n \r\n chunk = [].concat.apply([], chunk);\r\n \r\n var isChunkValid = chunk.every(function (item, i) {\r\n if (item === empty) {\r\n return true; \r\n }\r\n return chunk.indexOf(item, i \u002B 1) \u003C= 1;\r\n });\r\n chunk = [];\r\n return isChunkValid;\r\n }\r\n \r\n function checkRowValid(row, item, rowIndex) {\r\n return item !== empty \u0026\u0026 row.indexOf(item, rowIndex \u002B 1) !== -1;\r\n }\r\n \r\n function checkColumnValid(grid, rowIndex, colIndex) {\r\n var entries = 0;\r\n for (var row = 0; row \u003C grid.length; row\u002B\u002B) {\r\n if (grid[row][colIndex] !== empty \u0026\u0026 grid[rowIndex][colIndex] === grid[row][colIndex]) {\r\n entries\u002B\u002B;\r\n }\r\n }\r\n return entries \u003E 1;\r\n }\r\n}\r\n\r\nsudoku2(data);","IsDeferred":false},{"Name":"thre","Code":"function sudoku2(grid) {\r\n\tfor(var x = 0; x \u003C grid.length; x\u002B\u002B) {\r\n\t\tvar checkRow = {};\r\n\t\tvar checkColumn = {};\r\n\t\tvar checkSquare = {};\r\n\t\tvar offsetX = Math.floor(x/3) * 3;\r\n\t\tvar offsetY = (x % 3) * 3;\r\n\t\tfor(var y = 0; y \u003C grid.length; y\u002B\u002B) {\r\n\t\t\tvar squareX = Math.floor(y/3) \u002B offsetX;\r\n\t\t\tvar squareY = (y % 3) \u002B offsetY;\r\n\t\t\tif (isBroken(checkRow, grid[x][y]) || isBroken(checkColumn, grid[y][x]) || isBroken(checkSquare, grid[squareX][squareY])) {\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tfunction isBroken(check, value) {\r\n\t\treturn (check[value] \u0026\u0026 value !== \u0027.\u0027) || !(check[value] = true);\r\n\t}\r\n\treturn true;\r\n};\r\n\r\nsudoku2(data);","IsDeferred":false}]}