copySudoku static method
Returns an identical copy of the provided sudoku
.
InvalidSudokuConfigurationException is thrown if the configuration of
the sudoku
is not valid.
Implementation
static List<List<int>> copySudoku(List<List<int>> sudoku) {
if (!isValidConfiguration(sudoku)) {
throw InvalidSudokuConfigurationException();
}
var copiedSudoku = List.generate(9, (i) => List.generate(9, (j) => 0));
for (var i = 0; i < 9; i++) {
for (var j = 0; j < 9; j++) {
copiedSudoku[i][j] = sudoku[i][j];
}
}
return copiedSudoku;
}