Exploring Problem Solving with Python and Jupyter Notebook #1
Skills:
Python for Data80%
Key Takeaways
The video explores problem solving using Python and Jupyter Notebook, applying George Polya's method from "How to Solve It" to a programming problem, implementing a solution and optimizing it.
Full Transcript
in this video i want to talk about a kind of open-ended exploration of problem solving through the use of jupiter notebooks and the example i want to use is a simple programming problem so the problem reads so you have the numbers one two three and three two one and they contain the same digits but in a different order now find the smallest positive integer x such that two times x two times x four times x five times x and see six times x contain the same digits now the what i want to do this video is i want to go through my kind of implementation of george polya's how to solve a book where he outlines a method for problem solving which was intended initially for math teachers but in this case i think it applies very well to uh programming problems so let's take a look so the first thing that uh that we want to do is ask what is the unknown right so what is the unknown well in this case the unknown is an integer number that we want to find out all right okay so next thing is what's the data available so the data available are in this case well math and the rules and logic of math as well as the numbers that we're considering which in this case are x 2x 2 times x 4 times x 5 times x 6 x so what is the condition the condition is the main aspect of your problem right the core of your problem in this case is that we want to find a number with a given set of multiples that will have the same digits between them right so so that's the general condition now the next question that we have to ask is if it's possible to satisfy the condition usually when we do this it's a big heuristic where we have to kind of guess based on our first assumption of the problem in this case it seems to me that it's very possible and and now one of my favorite parts break the condition down to the smallest parts now this is where we go back to the problem description and we try to break it down the problem into its smallest bits in a way that makes it clear what's the path that we have to go through to be able to solve it in this case i think that a good way to describe it is first we have the numbers to consider x 2x 3x 4x 5x and 6x obviously they have to have the same digits and then the answer should be the smallest integer possible and finally we have to devise a plan so now devising a plan and when we're doing programming in my head would be doing pseudocode so in this case the pseudocode for this problem would be well we'll start with the number x equal to one would that create an infinite loop we'll then calculate 2 times x 3 times x et cetera well then for each multiple calculated we'll check its digits and then if the digits in all the numbers 2x 3x for x5x and 6x i'm saying we'll stop the iteration and return x right if they're not we're going to update x to x plus one that will continue until we found x so that would be kind of like my version of the plan in this case so let's let's go ahead and now it's the face to execute the plan meaning writing the code and we're going to test each component during the process because the the part about plan execution is to follow the steps in the pseudo while checking that each step is correct if we can check it so let's get rid of this for now let's forget about these three functions and let's go through the basically now we're going to do is we're going to get a pseudocode and what i do is i just copy it i copy the pseudocode as comments in the code part and each line should have an implementation of that line of sugar so in this case we'll start with the number uh x equal to one we'll then start uh start a infinite loop we'll calculate the multiples well then uh for each multiple that is calculated we'll check the the digits so in this case we'll append to a list all the digits from that from the number uh from that multiple in this case and then we'll check it so this function that i wrote here called check digits we'll check that all the lists of sorted digits inside that list are the same and why sorted because the get digits function will return a sorted list of digits given a given a number and why sorted because this was in my uh like my first view of this problem the best way to guarantee that we would have we could check the same digits in cases where the digits are out of order right with each other and if that check returns true we'll break the we'll break the loop if it's not we'll update x and then the good thing is that when we run it um we get this result which i know it to be true so that's great so this was a simple example now what we can do is we can look back and review the code in the solution right this should be a integral part of any kind of problem-solving system where we always look back regardless of having found a solution or not so we reviewed the code so we check that everything looks right we add add a little bit of documentation we check our assumptions we check our we check our reasoning we check if we you know any kind of like syntax error that kind of stuff and then we ask ourselves can we check the result in this case uh yes because either to be correct because this is from a list of programming exercises for which i have the solution and finally think about how i could optimize the code or derive the solution different can can i derive this solution differently can i make my solution better so i look at it as the same i look at it as the same problem in this case uh yes i noticed one thing when i was doing the solution which is for the uh variable num digits list i instead of initializing it as a list that i append over the multiple calls of the get digits function what i could do is just do one list comprehension to make the code a little bit better right so i implemented this line which you're seeing here and now what i did is i re-implemented the entire code in the cell with this this different implementation so that i could compare with the previous implementation so if we do that now here we can do a quick check and we're timing that cell execution to see uh how our code performs so this is our this is our results 1.24 seconds and now we can test our let's say our optimization our improvement of the previous solution and now we can check let's see if we got better so 1.24 plus 93.5 1.24 plus 113 so we didn't get like a gigantic improvement let's like do another check to make sure but like we got a very small improvement which in this case is great because the point is not to get like a gigantic improvement or anything like that but to actually just uh make sure we always try to implement an optimized version of a solution before you know handing that solution or before you know finishing with the problem so here we can see that now it was a little bit better so 1.33 versus 1.28 so this second version will be our final version let's say or the solution to the problem and finally before we wrap up we ask ourselves can we use the result for some other problem and in this case i can definitely use components of this answer for other problems like the functions get digits and check digits so i'll make sure to create a snippet of those functions because they're clearly reusable for other situations or problems because sorting um sorting a list of digits given a number that could be reused this is checking if all the items inside of a list are the same this is also very usable that's pretty much it that's uh that's what i wanted to talk about today i want to do a series of sort of open-ended explorations of problem solving through the scope of programming which for me is super useful thanks a lot for watching if you liked the video don't forget to subscribe to like and subscribe and that's it cheers
Original Description
This is the first video of a series where we will explore an implementation of the problem solving techniques described in the "How to Solve It" book by George Polya applied to programming problems using Python and Jupyter Notebook.
The goal is to evolve a system for thinking about problems in general using Jupyter Notebooks and Python and the tools of choice to conduct this exploration.
***If you liked this video don't forget to like and subscribe! Thanks and see you next time! :)***
Link to a review of the book:
- https://www.goodreads.com/book/show/192221.How_to_Solve_It
Socials:
- Follow me on Medium: https://lucas-soares.medium.com/
- Join Medium: https://lucas-soares.medium.com/membership
- Twitter: https://twitter.com/LucasEnkrateia
- LinkedIn: https://www.linkedin.com/in/lucas-soares-969044167/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Automata Learning Lab · Automata Learning Lab · 3 of 60
1
2
▶
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
A Quick Tutorial on NLP Basics
Automata Learning Lab
Automating your Digital Morning Routine with Python
Automata Learning Lab
Exploring Problem Solving with Python and Jupyter Notebook #1
Automata Learning Lab
Summarize Papers with Python and GPT-3
Automata Learning Lab
An Experiment Tracking Tutorial with Mlflow and Keras
Automata Learning Lab
Automating Google Forms Submissions with Python
Automata Learning Lab
Productivity Tracking With Python and the Notion API
Automata Learning Lab
When your Machine Learning Model Fails Do This ;p
Automata Learning Lab
Machine Learning Tip#1 Practical Deep Learning Course
Automata Learning Lab
Machine Learning Tips: Deep Learning Monitor
Automata Learning Lab
Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Automata Learning Lab
Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automata Learning Lab
Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Automata Learning Lab
Automating VS Code Snippets with Python
Automata Learning Lab
How to Set Up a Machine Learning Environment with Conda and Pip-Tools
Automata Learning Lab
9 Google Search Tips for Machine Learning
Automata Learning Lab
Thinking Tools
Automata Learning Lab
Automating Car Search with Python and Data Science
Automata Learning Lab
Generating Images from Text with Stable Diffusion and Hugging Face
Automata Learning Lab
A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
Automata Learning Lab
Jiu Jitsu App with Python and Streamlit
Automata Learning Lab
2 Apps for Coding In The Ipad Pro
Automata Learning Lab
From Tensorflow to Pytorch?
Automata Learning Lab
Building an Audio Transcription App with OpenAI Whisper and Streamlit
Automata Learning Lab
Productivity Tracking with Python Short Summary
Automata Learning Lab
Automating Expense Reports with Python
Automata Learning Lab
ChatGPT, Angry Pandas and AI Code
Automata Learning Lab
7 Strategies To Learn Anything Using ChatGPT
Automata Learning Lab
Building a Thought Summarization App with Whisper and GPT3
Automata Learning Lab
Visualize a Neural Net Learning Polynomial Functions
Automata Learning Lab
Automating Notion with Python
Automata Learning Lab
Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Automata Learning Lab
Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Automata Learning Lab
ChatGPT API Released by OpenAI
Automata Learning Lab
ChatGPT API Response Format #machinelearning #ai #datascience
Automata Learning Lab
Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Automata Learning Lab
Beyond Diffusion Models with Composer #machinelearning #ai
Automata Learning Lab
Machine Learning for Jiu Jitsu
Automata Learning Lab
Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Automata Learning Lab
Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Automata Learning Lab
Visual ChatGPT #machinelearning #ai #artificialintelligence
Automata Learning Lab
LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
Automata Learning Lab
Summarize Papers with Python and ChatGPT
Automata Learning Lab
Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Automata Learning Lab
Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Automata Learning Lab
Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Automata Learning Lab
Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Automata Learning Lab
How to Talk to a PDF using LangChain and ChatGPT
Automata Learning Lab
Query Your Own Notes With LangChain
Automata Learning Lab
HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
Automata Learning Lab
Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Automata Learning Lab
Automating Anki Flashcards with OpenAI and GPT-4
Automata Learning Lab
Building A PDF Summarization App with Gradio and LangChain
Automata Learning Lab
Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Automata Learning Lab
DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
Automata Learning Lab
LLMs for Research and Planning #artificialintelligence #gpt4 #llms
Automata Learning Lab
How I Use ChatGPT for Interactive Language Learning
Automata Learning Lab
Building an Audio Transcription App with Gradio and Whisper
Automata Learning Lab
Summarizing and Querying Multiple Papers with LangChain
Automata Learning Lab
Mojo - The New AI Programming Language?
Automata Learning Lab
More on: Python for Data
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
FREE AI Sin City Photo Generator — Turn Any Photo Into High-Contrast Noir Art (2026)
Dev.to AI
Google makes Gemini’s personalized image generation free for all US users
The Next Web AI
Gemini’s personalized AI image generation is now free for U.S. users
TechCrunch AI
WebP's Compression Secret: How a 1MB PNG Becomes a 200KB WebP
Dev.to · swift king
🎓
Tutor Explanation
DeepCamp AI