public SudokuGrid ParseGrid(string text) { var split = text.Split(';'); var grid = SudokuGrid.ParseGrid(int.Parse(split[0].ToString()), split[1].Split(',').Select(int.Parse).ToArray()); return(grid); }
public static SudokuGrid ParseGrid(int dimensions, int[] numbers) { // get data as array of arrays var rows = Enumerable.Range(0, dimensions).Select(i => numbers.Skip(i * dimensions).Take(dimensions).ToArray()).ToArray(); // put into 2D array int[,] grid = new int[dimensions, dimensions]; for (int i = 0; i < dimensions; i++) { for (int j = 0; j < dimensions; j++) { grid[i, j] = rows[i][j]; } } var sudokuGrid = new SudokuGrid(dimensions, grid); return(sudokuGrid); }