freeCodeCamp: Sudoku Solver Example Rejects Valid Input
Describe the Issue
The example Sudoku Solver rejects valid input.
Affected Page
https://sudoku-solver.freecodecamp.rocks/
Your code
Input the following and click “Solve”:
........................................................8.................6......
Expected behavior
It should produce a solved Sudoku puzzle.
Screenshots

System
Device: Laptop OS: Ubuntu 18.04.5 LTS Browser: Chromium Version: 90.0.4430.72
Additional context
https://github.com/freeCodeCamp/demo-projects/tree/main/apps/sudoku-solver
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (11 by maintainers)
Hi @diegoperezm, the reason appears to simply be a function of the way that the original solving algorithm proceeds through evaluating possible solution values. When that particular algorithm is used to solve either of your revised starting states (i.e. replacing the ‘8’ with a ‘1’ or ‘2’), it happens to need many fewer recursions (around 300) than the 250,000+ recursions needed to solve the original “8-6” starting state. Your revised starting states (“8-1” and “8-2”) are accepted because the number of recursions they require to be solved is below the “recursion limit” set in the code to prevent overconsumption of compute resources.
(I haven’t played around with many variations of starting puzzle states (and I’m not a mathematician), so I can’t say whether there’s a reason for the difference in number-of-required-recursions between these starting values, beyond “it’s just a function of the algorithm ¯_(ツ)_/¯”.)
I do agree, however I think there’s need to more clearly indicate the perfection is not the goal.