Python Sudoku Solver Tutorial with Backtracking p.2

preview_player
Показать описание
This Sudoku solver tutorial uses python and the backtracking algorithm to find a solution to any solvable sudoku board. In this part of the tutorial we will fully implement the algorithm discussed in part 1.

◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python

◾◾◾◾◾◾

⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
Tags:
- Tech With Tim
- Sudoku Solver Python
- Python sodoku sovler tutorial
- Python sodoku
- Soudku solver with backtracking
- Python Tutorials
Рекомендации по теме
Комментарии
Автор

Could you do one more episode of this where you make a gui of this

andrewm
Автор

For anyone who is confused with the valid function (as I and many others were), wait until he creates the solve function and actually uses it. Then, it makes a lot more sense.

ashwinbabu
Автор

I watched this video last year over and over but couldnt get my head around it, I finally clicked to watch it again today determined to succeed, and satisfyingly, I did just that! Thanks Tim

henryash
Автор

8:34
Tim : to do this, it is actually very straightforward
Me : oh okay
Tim : we're gonna do it recursively
Me : (°-° )

amirfirdaus
Автор

Beautiful. Simply put. This is the best video I ve found for Sudoku backtracking. Its also amazing how little space you need for the whole code.

asdfasdfasdf
Автор

Confusing moment when I did understand how x/y is handled here. Damn that was painful to go through in the valid() function part!
This is brillant!
 Thanks !

nktslp
Автор

I did find bits confusing and poorly explained (lines 17-20 for example) but overall you explained the concept of backtracking pretty well and this gave me good insight into what it is. Thanks!

flamexc
Автор

Dude one year have passed and i came back here to do this algorithm translating him do c# and damn this still pretty awesome. thank u a lot

diegocelestino
Автор

Really cool! I've been pondering over solving the sudoku solver problem for a long time and did not think of recursion as an option! Thanks for making this video...

minimationsinc.
Автор

i cannot express how legendary you are for these vids. thank you man

Lafret
Автор

Keep up the content bro, i'm learning a lot!

TheJChrest
Автор

Really good tutorials! @2:20 isn't necessary, since we haven't written the selected number to the blank cell yet at this point. The code works with or without this second condition.

baphnie
Автор

When I came here I didn't know how to use backtracking really, and even less I know how to play Sudoku. Now I know both, after taking apart your code I can say it is brilliant example. Subscribed.

besllu
Автор

Thanks mate! Its fun to code these algorithms because i remember coding a maze algorithm with recursive algorithm and memories begin flashing my eyes.

HealthInspectorz
Автор

Hi Tim,


First, great job. I enjoyed the videos. It is easy to understand for beginners, short code. For fun I am doing a sudoku module, and yes, it does have more bells and whistles. But just the bactracking and my sudoku grid object takes about a hundred lines of python code more than yours. I do see one single problem with your solution: Your code can find if a grid has no solution or has a solution, but it does not figure out if the solution is unique. That is an important part of a puzzle.


On the other hand, like you, I have a grid that I use to test. I found it randomly online, I cannot even tell you exactly where. But with that grid, your code is not as immediate. You can try it. In my machine (2017 laptop with i5 processor) it took 15 seconds to find a single solution. About half the time it took my code to find that it was the only solution. I post the matrix here.


grid = np.array([
(6, 0, 0, 0, 0, 0, 0, 5, 1),
(0, 0, 0, 3, 0, 0, 9, 0, 0),
(0, 0, 8, 0, 0, 0, 0, 0, 0),
(0, 4, 0, 7, 0, 0, 5, 0, 0),
(0, 0, 0, 0, 9, 0, 8, 0, 0),
(0, 0, 1, 8, 5, 0, 0, 3, 7),
(5, 0, 2, 6, 0, 0, 0, 0, 4),
(3, 0, 0, 0, 0, 7, 0, 2, 9),
(0, 0, 4, 0, 0, 0, 0, 0, 0)
])


Again, even with this comment, great job. Once you graduate, you should teach. You are good at it. Believe me, I am a college professor.

davidjimenezlopez
Автор

Love the code. Integer division great trick. Thanks for sharing! Inspired me to write my own and try for less than 100 lines before watching this seeing what you did!

braxtonec
Автор

Spends a week trying to make a back tracking algo by myself*
Finds this video, follows along, everything makes sense, and finishes a project in 20 minutes*
Man I love programming :')

kylejames
Автор

I came here to learn more about backtracking, and I did. I knew of the channel before, but now I'm a subscriber - please make more videos like this. Thank you!

alexb
Автор

Thanks a lot. The recursion bit was a bit hectic but this was a really good explanation especially for self-taught developers who don't know some of this concepts from a classroom.

nnhh
Автор

hey tim, i got to say: your content is pretty awesome. i'm here from brazil learning a lot with your videos, dude. this video is from a some time ago but i keep following you every day. a great hug man

diegocelestino