public SudokuWithLegalValues Clone() { SudokuGrid clonedGrid = new SudokuGrid { }; for (int i = 0; i < Size; i++) { List <List <byte> > newRow = new List <List <byte> >(); for (int j = 0; j < Size; j++) { List <byte> clonedLegalValues = new List <byte>(); foreach (byte item in Grid[i][j]) { clonedLegalValues.Add(item); } newRow.Add(clonedLegalValues); } clonedGrid.Add(newRow); } SudokuWithLegalValues newInstance = new SudokuWithLegalValues(clonedGrid); return(newInstance); }
public SudokuWithLegalValues ToSudokuWithLegalValues() { SudokuGrid resultGrid = new SudokuGrid { }; for (int rowIndex = 0; rowIndex < Size; rowIndex++) { resultGrid.Add(new List <List <byte> > { }); for (int colIndex = 0; colIndex < Size; colIndex++) { resultGrid[rowIndex].Add(GetPossibleValuesSet(Grid[rowIndex, colIndex], Size)); } } SudokuWithLegalValues result = new SudokuWithLegalValues(resultGrid); return(result); }
public SudokuWithLegalValues CloneWithNewValue(int row, int col, byte value) { SudokuGrid clonedGrid = new SudokuGrid { }; for (int i = 0; i < Size; i++) { List <List <byte> > newRow = new List <List <byte> >(); for (int j = 0; j < Size; j++) { if (row == i && col == j) { newRow.Add(new List <byte> { value }); continue; } List <byte> clonedLegalValues = new List <byte>(); foreach (byte item in Grid[i][j]) { clonedLegalValues.Add(item); } newRow.Add(clonedLegalValues); } clonedGrid.Add(newRow); } SudokuWithLegalValues newInstance = new SudokuWithLegalValues(clonedGrid); return(newInstance); }