2 ms·
while (!isSolved(sudoku)) { sudoku = generateNextPermutation(sudoku); } Solved (eventually).
by marginalia_nu 5y ago
while (!isSolved(sudoku)) {
sudoku = generateNextPermutation(sudoku);
}
Solved (eventually).
- Cthulhu_ 5y agoA bogosolver is a valid approach. I mean it'll take forever, but it's valid.
- marginalia_nu 5y agoI plead the halting problem.
- wccrawford 5y agoThere are a limited number of permutations. Assuming it's not choosing them randomly, it'll finish eventually... If the hardware doesn't die first.
- tonyedgecombe 5y agoYou can solve it via brute force if you cut off branches that don't satisfy the rules: https://github.com/tonyedgecombe/Sudoku/blob/master/Sudoku/Program.cs https://github.com/tonyedgecombe/Sudoku/blob/master/Sudoku/P... It's not 1ms but it's not that slow either.