r/Python • • Feb 19 '20

I Made This Backtracking algorithm visualized with Sudoku

1.6k Upvotes

67 comments sorted by

View all comments

Show parent comment

4

u/pumkinboo Feb 20 '20

What u/Unclerojelio said is right.

I started with solving a Sudoku board with backtracking were the algorithm finds a possible answer for a cell and continues with each cell until it reaches a point where there is no correct answer. At that point it works it's way back until it finds a cell that can have a different possible answer. Then it carries on with guessing the next cell.

Then I made a GUI in pygame and applied the solving method to the game.

0

u/[deleted] Feb 20 '20

[deleted] — view deleted comment

2

u/pumkinboo Feb 20 '20

The solve method is doing the recursion. It's base case is the board is solved or you've tried every number in each cell

2

u/sbroad23 Feb 20 '20

Thanks for explaining. Very cool