private bool MakeRec(int difficult, ref Sudoku puzzle) { var cou = 0; foreach (var elem in puzzle.Matrix) { if (elem == 0) { cou++; } } /*Console.WriteLine(cou);*/ if (difficult == cou) { return(true); } else { var iter = Size; while (true) { if (iter == 0) { break; } int rem; while (true) { rem = rnd.Next(0, Size * Size * Size * Size); if (puzzle.Matrix[rem] != 0) { break; } } iter--; /* Console.WriteLine(rem);*/ puzzle.Matrix[rem] = 0; if (Recursive.IsSolutionOlnyOne(puzzle)) { if (MakeRec(difficult, ref puzzle)) { return(true); } } else { return(false); } } return(false); } }
public List <int> Solve(List <int> input) { return(Recursive.Solve(new Sudoku(input.ToArray())).Matrix); }