Solving Sudoku with AI | Learning Intelligence 1

Daniel Bourke · Beginner ·📰 AI News & Updates ·8y ago

Key Takeaways

This video teaches solving Sudoku puzzles using artificial intelligence techniques from the Udacity Artificial Intelligence Nanodegree

Full Transcript

hello y'all what's going on we're back with another series I don't know what I'm gonna call this one yet maybe learning intelligence or building intelligence I think learning until it is the good one why is that well because I'm studying my artificial intelligence then degree on Udacity and by the way if you've seen my other videos yes I didn't shave my head yes it is incredibly short and my friend cut my hair long story short I felt like cutting all my hair off not this short but it'll grow back right so I took a few days off because it was my birthday last Friday I'm 24 years old whoo and now I'm back into studying so I finished the deep learning now in degree you can see that series there in the hundred days of code series but I'm gonna start this is a new one I'll do I won't do too much of an intro on this video because I'll do another intro like a earlier on video introducing my goals and what not in in a future video so it'll be like Star Wars this think of this is like episode 1 and episode 0 is going to come sometime in the future but what have I been learning so we started off we're diving straight into it this is it's my first project and I've - already and we are a whole three hours into this course so it's true this Friday I believe yeah today is the Tuesday the 5th of September and if it's jus on the 8th I have to build I had artificial intelligence this is to solve any Sudoku puzzle I can barely solve Sudoku is myself check this out we go here this one here is like the example took me 49 minutes and 40 seconds what is that so by then this week I will have built an AI that consults to Dooku and I will show it all to you and as for this series I want to bring you along with my journey on sort of learning artificial intelligence and building things with it you can follow along on my trail board I'll link that in the description as well and also link an article by Peter Norvig who's like one of the fathers of artificial intelligence researcher at Google's deep brain or some sort of Google's lab deep mind maybe that is but yeah he wrote an article on how to solve every Sudoku puzzle using Python which i think is really cool I'm terrible at Sudoku so I'm just gonna build - may I - solve it for me or making progress on the Sudoku project - check this out it's a bit different this time it's not even Jupiter notebook my beloved Jupiter notebook for the projects it's all in an IDE which I still have to get used to so the project is to solve write write an algorithm to solve any sodoku implementing the naked twins technique so for example if two numbers have the same same two-digit possibility that they could be in Sudoku they considered naked twins I won't go too much into depth on that I'll just let you google it I think there's a Sudoku dragon is the website to check it out as well as the ability to solve a diagonal sodoku so not only with the columns and the rows and the level bosses but diagonally as well so these digits here along the diagonals they have to be 1 2 9 in container to just once not I've hit a bit of a roadblock was kind of doubting myself because I couldn't solve this one part of the challenge which is killing the naked twins part of it I'm trying to still I've never done acid oaken until yesterday well fully not that I can remember that's kind of like reconsidering my enrollment in a I never agree considering this is the first project and apparently it's one of the easier ones but then I remembered no I can work through this this is the point of it write it if it was easy everyone would be doing it so I've left myself I'm gonna finish off for the day take a break let it sink into my subconscious and I've left myself a little checklist here of what I can do next step so four little steps implement pleadin or via Cogan duper notebook because that's where I'm most familiar further understanding read through medium article go through Sudoku class before submission insert comments from class code into my submission code so just a bit of a checklist to work on tomorrow I think that's that's it that's a thing to remember is when you have a big project and you sort of look at the big picture like I was before and sort of having doubts about yourself if you break it down into small little steps and achieve each one of those steps suddenly something that was once big is now just a bunch of small little things you can take those off relatively easy so I'm gonna go work out check out my YouTube other videos for more workouts I think I'm gonna I want to post more workout videos actually and more cooking videos but this would be the final clip for today and we'll check back in tomorrow see if I've made progress I want to submit the submit the project by the end of tomorrow that's to it look at that the night shift mode is engaged you know it means I've been coding for a while get flunks by the way really helps as well but what I've been up to today going through this medium article which is actually really good I think I mentioned it in the previous clip Sudoku solver by Peter Norvig and it virtually breaks down all the steps that Peter Norvig talk to create is solving every Sudoku puzzle with AI so what about doing is reimplemented there article in Python notebook or juban notebook sorry - Jupiter notebook because that's where I'm most familiar I'm not entirely familiar with ideas and running code through through the terminal just yet so there's my Jupiter notebook check-ins over here so I've been trying to replicate it in a familiar territory before trying to put it back into the IDE before submission I'm not gonna be submitting here today which is I like I've sort of hit a roadblock I've been coding for about how long let's check it out we're working for three three souls on this problem let's concentrate allow us by the way so it's like um this is all I'm focused on and right now I sort of hit a hit of time where I'm like okay I need to take some time away go for a run or something clear my head so I can come back to it either later tonight probably not later tonight because as I have dinner my brain power will go down tomorrow morning get back into it a little submit tomorrow be a little bit past the due date that's the beauty of online courses is that you can as long as you submit them all before the sort of the cutoff date which is four weeks after the final assignment you can still pass it so I'll get this done tomorrow and I'll check in with you once it's done but I've also it works at the moment but I'm trying to implement the naked twins function which is the naked twins is a strategy to solve Sudoku but it does it is able to solve apparently the hardest Sudoku ever so it's making a liar of me now oh there we go sorry hardest ever Sudoku I I had a link to it before but essentially I finished mathematician I'll put in the description by the way I finished mathematician thought of the heart of Sudoku who could possibly make and it's apparently only summer by the brightest minds all the algorithm that's I created with the help of Udacity and Peter Norvig and the median are maybe an article of course but I'm gonna go for a run clear my head I should live stream to workout video today actually so check that out there will be somewhere on my channel but I'll see you more whoa finally got the project submitted it is almost 6 p.m. I was going for a lot longer than what I thought I would but look at this cool little message you submit things in the terminal now for Udacity projects well at least for this one so far results everything looks good and then you get a zip file that'll go into here into this folder and then I can upload it there but finally after I was working with sleep all day probably four or five hours on the naked twins function which is here I can't really explain it to at the moment because I'm a bit bit scatterbrained but essentially naked twins goes through all the Sudoku and finds all the boxes with two digits possibilities and then it finds all the boxes of those two-digit possibilities that have the same digits and then eliminates those digits from the other values in its peer group and now that was a lot to sort of take in and especially if you're not familiar with Sudoku and I'm nowhere near familiar with sodoku either but don't worry I think I may do a Jupiter notebook up for this with it more in depth and how how I actually went over this and potentially a blog post to go with it so if I do you'll be the first to know that but project one for the Udacity artificial intelligence nano degree is submitted whoo that was a little effort actually and that was apparently project one is one of the most easiest ones in the whole thing so I'm in for a good treat I learned a lot about Python and list comprehension in this one that's since what I think projects working on projects is really good for if you learn a lot more than than what you would sort of I know not implementing it all just going over different pieces of theory so if I've got to work on something in the future it's my Python just Python in general I think that's that's a big skill to have like if you're good at just programming in general and is a really good skill to have I've also got to work on sort of my ability to communicate what the program is actually doing so I think because I'm still such a novice at Python I'm I struggle to sort of understand what's going on line by line with the code but I find if I break it down myself and sort of comment on each line what what I think's doing I get a better understanding and also printing printing what each line is doing what each output what the each variable looks like that's really helpful for me but it's almost 6 p.m. I haven't eaten all day I'm gonna get some food and I'll check back in with you guys I think all in this video once I get my once I pass this project cuz that'll be like that'll be a good way to end the video get it get a project done so hopefully the next clip I'm getting feedback from my reviewer to say that I passed the project fingers crossed okay so the first time I submitted this Udacity project file I forgot to fill in these questions here in the readme file so let's see how did we use constraint propagation to solve a naked twins problem firstly find all the squares with only two possible solutions secondly of these squares find those with matching values these are considered the naked twins this constraints a possible options heavily once you've caught the naked twins find all the common pairs of these squares with the common P is known you can safely remove the possibility of the digits within the naked twins has been options for the peers of the naked twins now that is a mouthful but if you understand the naked print twins philosophy and I know I've talked it as a strategy sorry talked about that a lot in this video so if you're unfamiliar with Sudoku I apologize but so is actually pretty fun playing it on your own like I mean I know they say I can solve it in a few microseconds but playing it on your own it's it's a good fun my opinion so I resubmitted my project I won't read this one out Oh that'll be all my github later so you can read that resubmitted so let's see your project has been reviewed by the way Udacity support team Hawaii the fastest reviewers I know I've said this in the past fastest reviewers I've ever experienced so I submitted this and sort of went to have a break and then two hours later it was it was done it was reviewed but I'm not checking it to this morning because I wanted to film it as I as I checked it and apologize for no-show might be a bit sweaty I just went for a run it's Sunday morning where I lived I like to wake up and do some sort of physical activity and Sunday mornings but you're watching this as I'm watching this it means specifications so all done I put in the notes there how I was excited and submitting it too quickly without answering the questions I completely understand the feeling and being excited about you're getting a code to work well done I hope you have many more of it oh that's nice I really like new data videos so documentation very neatly formatted well done readme good answer good answer excellent and then oh I haven't seen this before let's see code review comments awesome good answer and suggestion it's not needed for this project but if you ever use this code to impress your friends and solve all the Sudoku puzzles you should remember to only include diagram new units when you need a diagonal puzzle that makes sense most of those who puzzles including the ones shown up in the newspapers don't have time or constraints I see and what I get here I think it anything okay I realized if I tap the autofocus on the iPhone it puts everything out of blur so I just gotta leave it on for a focus so don't tap if you're recording video and you want to make it keep it auto focusing but essentially Udacity reviewers are amazing the speed is incredibly quick one of my plans for the next week or the rest of today today I'm going to do some writing also drive some new below to us and get some cash and then mix or plan my next week as well and then next week I'm going to be working on week two of the AI nanodegree classes as well as some other things I think I'm going to publish some sort of blog post as well on how I'm learning artificial intelligence but I'll make sure you you get everything so thank you so much for watching we'll see you in the next video peace

Original Description

Solving Sudoku with AI The first installment of my new VLOG series, Learning Intelligence is here! Follow along I as I go through the Udacity Artificial Intelligence Nanodegree and other learnings on my journey towards building AI. Links mentioned in the video: Hardest Sudoku Ever by Finnish Mathematician - http://www.mirror.co.uk/news/weird-news/worlds-hardest-sudoku-can-you-242294 Medium Article on Sudoku - https://medium.com/towards-data-science/peter-norvigs-sudoku-solver-25779bb349ce Peter Norvig Blog Post on Creating a Sudoku Solving AI - http://norvig.com/sudoku.html Trello Board with My Self-Created AI Masters Degree - https://trello.com/b/tyHAvpcY Say Hi to me anywhere! Web: https://www.mrdbourke.com Quora: https://www.quora.com/profile/Daniel-Bourke-2 Instagram: https://www.instagram.com/mrdbourke/ Twitter: https://www.twitter.com/mrdbourke Email updates: http://bit.ly/mrdbourkenewsletter
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Daniel Bourke · Daniel Bourke · 32 of 60

1 Xbox One S Unboxing and Xbox One Comparison
Xbox One S Unboxing and Xbox One Comparison
Daniel Bourke
2 Text/Profanity Checker in Python
Text/Profanity Checker in Python
Daniel Bourke
3 Drawing Flowers in Python
Drawing Flowers in Python
Daniel Bourke
4 Finding The Right Medium - TDBS 18 April 2017
Finding The Right Medium - TDBS 18 April 2017
Daniel Bourke
5 What Is Neuralink??! - TDBS 22 April 2017
What Is Neuralink??! - TDBS 22 April 2017
Daniel Bourke
6 Disagree and Commit, Words of Wisdom from Jeff Bezos - TDBS 19 April 2017
Disagree and Commit, Words of Wisdom from Jeff Bezos - TDBS 19 April 2017
Daniel Bourke
7 A Lesson In Movement | Raw Training Australia
A Lesson In Movement | Raw Training Australia
Daniel Bourke
8 FALLING IS FUN | Functional Friday 4
FALLING IS FUN | Functional Friday 4
Daniel Bourke
9 My first HACKATHON! | 100 Days of Code 1
My first HACKATHON! | 100 Days of Code 1
Daniel Bourke
10 MORE MACHINE LEARNING | 100 Days of Code 2
MORE MACHINE LEARNING | 100 Days of Code 2
Daniel Bourke
11 TensorBoard and learning from Einstein | 100 Days of Code 3
TensorBoard and learning from Einstein | 100 Days of Code 3
Daniel Bourke
12 Job Interview Tips and Open Ocean Swim | 100 Days of Code 4
Job Interview Tips and Open Ocean Swim | 100 Days of Code 4
Daniel Bourke
13 I Want To Help 100,000 People Workout | AI Powered Personal Trainer
I Want To Help 100,000 People Workout | AI Powered Personal Trainer
Daniel Bourke
14 MACHINE LEARNING IN 5 MINUTES
MACHINE LEARNING IN 5 MINUTES
Daniel Bourke
15 COFFEE, YOGA and AWS | 100 Days of Code 5
COFFEE, YOGA and AWS | 100 Days of Code 5
Daniel Bourke
16 MY FIRST STARTUP WEEKEND | 100 Days of Code 6
MY FIRST STARTUP WEEKEND | 100 Days of Code 6
Daniel Bourke
17 GENERATING TV SCRIPTS WITH DEEP LEARNING | 100 Days of Code 7
GENERATING TV SCRIPTS WITH DEEP LEARNING | 100 Days of Code 7
Daniel Bourke
18 Attention, please
Attention, please
Daniel Bourke
19 TEACHING BOTS TO PLAY GAMES | 100 Days of Code 9
TEACHING BOTS TO PLAY GAMES | 100 Days of Code 9
Daniel Bourke
20 Udacity Deep Learning Nanodegree Language Translation Project Submission | 100 Days of Code 10
Udacity Deep Learning Nanodegree Language Translation Project Submission | 100 Days of Code 10
Daniel Bourke
21 Learning about Generative Adversarial Networks on Udacity | 100 Days of Code 11
Learning about Generative Adversarial Networks on Udacity | 100 Days of Code 11
Daniel Bourke
22 Completing Andrew Ng's Machine Learning Course on Coursera | 100 Days of Code 12
Completing Andrew Ng's Machine Learning Course on Coursera | 100 Days of Code 12
Daniel Bourke
23 Finishing the Treehouse Python Track | 100 Days of Code 13
Finishing the Treehouse Python Track | 100 Days of Code 13
Daniel Bourke
24 GENERATING FACES WITH GANs | 100 Days of Code 14
GENERATING FACES WITH GANs | 100 Days of Code 14
Daniel Bourke
25 Graduating From the Udacity Deep Learning Nanodegree | 100 Days of Code 15
Graduating From the Udacity Deep Learning Nanodegree | 100 Days of Code 15
Daniel Bourke
26 WHAT I'VE LEARNED FROM TALKING TO PEOPLE
WHAT I'VE LEARNED FROM TALKING TO PEOPLE
Daniel Bourke
27 3 Life Principles I Learned From Ray Dalio
3 Life Principles I Learned From Ray Dalio
Daniel Bourke
28 PYTHON && POETRY | 100 Days of Code 16
PYTHON && POETRY | 100 Days of Code 16
Daniel Bourke
29 Physique Update and 6 Things I Wish I Knew Before Starting Gym
Physique Update and 6 Things I Wish I Knew Before Starting Gym
Daniel Bourke
30 The 100 Days is Over! | 100 Days of Code 17
The 100 Days is Over! | 100 Days of Code 17
Daniel Bourke
31 How to Burn Over 100 Calories in 4 Minutes
How to Burn Over 100 Calories in 4 Minutes
Daniel Bourke
Solving Sudoku with AI | Learning Intelligence 1
Solving Sudoku with AI | Learning Intelligence 1
Daniel Bourke
33 Upper Body Calisthenics Workout in the Park
Upper Body Calisthenics Workout in the Park
Daniel Bourke
34 What is an Adversarial Search Agent? | Learning Intelligence 2
What is an Adversarial Search Agent? | Learning Intelligence 2
Daniel Bourke
35 My Self-Created Artificial Intelligence Master's Degree | Learning Intelligence 0
My Self-Created Artificial Intelligence Master's Degree | Learning Intelligence 0
Daniel Bourke
36 Try Going Over It Again | Learning Intelligence 3
Try Going Over It Again | Learning Intelligence 3
Daniel Bourke
37 Python and Pullups | Learning Intelligence 4
Python and Pullups | Learning Intelligence 4
Daniel Bourke
38 AI Meets Blockchain! | Learning Intelligence 5
AI Meets Blockchain! | Learning Intelligence 5
Daniel Bourke
39 How to Pass the Turing Test + I FAILED | Learning Intelligence 6
How to Pass the Turing Test + I FAILED | Learning Intelligence 6
Daniel Bourke
40 Biology and Physics meet Computer Science | Learning Intelligence 7
Biology and Physics meet Computer Science | Learning Intelligence 7
Daniel Bourke
41 Udacity Artificial Intelligence Nanodegree Project 3 Progress | Learning Intelligence 8
Udacity Artificial Intelligence Nanodegree Project 3 Progress | Learning Intelligence 8
Daniel Bourke
42 Passing Project 3 of Udacity's Artificial Intelligence Nanodegree | Learning Intelligence 9
Passing Project 3 of Udacity's Artificial Intelligence Nanodegree | Learning Intelligence 9
Daniel Bourke
43 Bayes Networks, Hidden Markov Models and How I Wake Up | Learning Intelligence 10
Bayes Networks, Hidden Markov Models and How I Wake Up | Learning Intelligence 10
Daniel Bourke
44 Udacity AI Nanodegree Progress and Bayes' Rule Explained | Learning Intelligence 11
Udacity AI Nanodegree Progress and Bayes' Rule Explained | Learning Intelligence 11
Daniel Bourke
45 Udacity AI Nanodegree Project 4 Planning and Progress | Learning Intelligence 12
Udacity AI Nanodegree Project 4 Planning and Progress | Learning Intelligence 12
Daniel Bourke
46 Finishing Term 1 of Udacity's Artificial Intelligence Nanodegree | Learning Intelligence 13
Finishing Term 1 of Udacity's Artificial Intelligence Nanodegree | Learning Intelligence 13
Daniel Bourke
47 deeplearning.ai Progress! | Learning Intelligence 14
deeplearning.ai Progress! | Learning Intelligence 14
Daniel Bourke
48 Coursera Deep Learning Specialization Progress | Learning Intelligence 15
Coursera Deep Learning Specialization Progress | Learning Intelligence 15
Daniel Bourke
49 Computer Vision Basics + More deeplearning.ai Progress! | Learning Intelligence 16
Computer Vision Basics + More deeplearning.ai Progress! | Learning Intelligence 16
Daniel Bourke
50 My Experience at CodeCamp, Intro to Keras and Failing Hard | Learning Intelligence 17
My Experience at CodeCamp, Intro to Keras and Failing Hard | Learning Intelligence 17
Daniel Bourke
51 In-Depth Udacity Deep Learning Nanodegree Review
In-Depth Udacity Deep Learning Nanodegree Review
Daniel Bourke
52 Completing the Deeplearning.ai Specialization on Coursera | Learning Intelligence 18
Completing the Deeplearning.ai Specialization on Coursera | Learning Intelligence 18
Daniel Bourke
53 You're Never Too Young to Start Learning AI - Learning Intelligence Talks with Shaik Asad
You're Never Too Young to Start Learning AI - Learning Intelligence Talks with Shaik Asad
Daniel Bourke
54 Starting Term 2 of the Udacity Artificial Intelligence Nanodegree | Learning Intelligence 19
Starting Term 2 of the Udacity Artificial Intelligence Nanodegree | Learning Intelligence 19
Daniel Bourke
55 Submitting the Computer Vision Capstone Project | Udacity AI Nanodegree | Learning Intelligence 20
Submitting the Computer Vision Capstone Project | Udacity AI Nanodegree | Learning Intelligence 20
Daniel Bourke
56 Leg Day at World Gym Northlakes ft. Ben Jones Fitness
Leg Day at World Gym Northlakes ft. Ben Jones Fitness
Daniel Bourke
57 deeplearning.ai Sequence Models Course Progress | Learning Intelligence 21
deeplearning.ai Sequence Models Course Progress | Learning Intelligence 21
Daniel Bourke
58 Graduating from the deeplearning.ai Coursera Specialization | Learning Intelligence 22
Graduating from the deeplearning.ai Coursera Specialization | Learning Intelligence 22
Daniel Bourke
59 Udacity Artificial Intelligence Nanodegree NLP Concentration Progress | Learning Intelligence 23
Udacity Artificial Intelligence Nanodegree NLP Concentration Progress | Learning Intelligence 23
Daniel Bourke
60 Learning How to Build What's Next at Google Cloud On Board Brisbane
Learning How to Build What's Next at Google Cloud On Board Brisbane
Daniel Bourke

Related Reads

Up next
Why India Needs a New Kind of Hardware Engineer | Kunal Ghosh, Co-Founder at VSD | Scaler Pod
SCALER
Watch →