Commit 231bd1be authored by Yannick Li's avatar Yannick Li
Browse files

Change static grid

parent 55633048
...@@ -133,7 +133,7 @@ class Grid extends React.Component<IGridProps, IGridState> { ...@@ -133,7 +133,7 @@ class Grid extends React.Component<IGridProps, IGridState> {
* @param values values to be set in the MVMap. * @param values values to be set in the MVMap.
*/ */
initFrom(values:any) { initFrom(values:any) {
assert.ok(values.length == 81); assert.ok(values.length === 81);
let cells = this.state.cells; let cells = this.state.cells;
for (let i = 0; i < 81; i++) { for (let i = 0; i < 81; i++) {
cells[i][0] = values[i] === "." ? "" : values[i]; cells[i][0] = values[i] === "." ? "" : values[i];
...@@ -386,16 +386,18 @@ class Grid extends React.Component<IGridProps, IGridState> { ...@@ -386,16 +386,18 @@ class Grid extends React.Component<IGridProps, IGridState> {
* Return a predefined Sudoku grid as a string. * Return a predefined Sudoku grid as a string.
*/ */
function generateStaticGrid() { function generateStaticGrid() {
const values = "\ /**
6.2387914\ * 32.17.654
719452368\ * 6152947..
348196257\ * .783.6291
821935476\ * .574.2816
59.274831\ * 18.7659.2
473861529\ * 236.1.54.
187529..3\ * 742.813.9
234618795\ * 8.36.7125
.65743182" * 56.9234.8
*/
const values = "32.17.6546152947...783.6291.574.281618.7659.2236.1.54.742.813.98.36.712556.9234.8"
assert.ok(values.split('').every(x => (x === "." || (Number(x) >= 1 && Number(x) <= 9)))); assert.ok(values.split('').every(x => (x === "." || (Number(x) >= 1 && Number(x) <= 9))));
return values; return values;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment