u/bleachisbackin r/rust • Recommends
On “Sudoku solver and generator in rust”
You should consider using something like dancing links to generate and solve your puzzles. Your implementation has one major problem right now: your generator can actually generate non-valid puzzles. An important rule for sudoku puzzles to be valid is that they must admit a unique solution. You’re currently brute forcing your solution, so you find the “first” solution and ignore any other ones.
As well, your brute force solution idea will be fine for the most part, but if you ever add the feature for people to manually put in their own puzzles, I’d be able to create an initial puzzle that forced someone’s computer to go through every possibility, and DOS a core on their computer for a whi…