private void convertSolutionToSudoku(DlxLib.Solution s, int[,] m) { foreach (int row in s.RowIndexes) { int x = 0, y = 0, nb = 0; for (int j = 0; j < 81; j++) { if (m[row, j] == 1) { x = j % 9; y = j / 9; break; } } for (int j = 81; j < 162; j++) { if (m[row, j] == 1) { nb = (j - 81) % 9 + 1; break; } } sudoku.setCaseSudoku(y, x, nb); //sudoku.setCaseSudoku((nb / 9), (nb % 9), (row % 10) + 1); } }
public void Solve() { matrixBuilder(); DlxLib.Solution tmp = sol.Solve(matrix).FirstOrDefault(); if (tmp != null) { convertSolutionToSudoku(tmp, matrix); } }