Exploring Problem Solving with Python and Jupyter Notebook #1

Automata Learning Lab · Intermediate ·🎨 Image & Video AI ·4y ago

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 A Quick Tutorial on NLP Basics
A Quick Tutorial on NLP Basics
Automata Learning Lab
2 Automating your Digital Morning Routine with Python
Automating your Digital Morning Routine with Python
Automata Learning Lab
Exploring Problem Solving with Python and Jupyter Notebook #1
Exploring Problem Solving with Python and Jupyter Notebook #1
Automata Learning Lab
4 Summarize Papers with Python and GPT-3
Summarize Papers with Python and GPT-3
Automata Learning Lab
5 An Experiment Tracking Tutorial with Mlflow and Keras
An Experiment Tracking Tutorial with Mlflow and Keras
Automata Learning Lab
6 Automating Google Forms Submissions with Python
Automating Google Forms Submissions with Python
Automata Learning Lab
7 Productivity Tracking With Python and the Notion API
Productivity Tracking With Python and the Notion API
Automata Learning Lab
8 When your Machine Learning Model Fails Do This ;p
When your Machine Learning Model Fails Do This ;p
Automata Learning Lab
9 Machine Learning Tip#1 Practical Deep Learning Course
Machine Learning Tip#1 Practical Deep Learning Course
Automata Learning Lab
10 Machine Learning Tips: Deep Learning Monitor
Machine Learning Tips: Deep Learning Monitor
Automata Learning Lab
11 Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Automata Learning Lab
12 Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automata Learning Lab
13 Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Automata Learning Lab
14 Automating VS Code Snippets with Python
Automating VS Code Snippets with Python
Automata Learning Lab
15 How to Set Up a Machine Learning Environment with Conda and Pip-Tools
How to Set Up a Machine Learning Environment with Conda and Pip-Tools
Automata Learning Lab
16 9 Google Search Tips for Machine Learning
9 Google Search Tips for Machine Learning
Automata Learning Lab
17 Thinking Tools
Thinking Tools
Automata Learning Lab
18 Automating Car Search with Python and Data Science
Automating Car Search with Python and Data Science
Automata Learning Lab
19 Generating Images from Text with Stable Diffusion and Hugging Face
Generating Images from Text with Stable Diffusion and Hugging Face
Automata Learning Lab
20 A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
Automata Learning Lab
21 Jiu Jitsu App with Python and Streamlit
Jiu Jitsu App with Python and Streamlit
Automata Learning Lab
22 2 Apps for Coding In The Ipad Pro
2 Apps for Coding In The Ipad Pro
Automata Learning Lab
23 From Tensorflow to Pytorch?
From Tensorflow to Pytorch?
Automata Learning Lab
24 Building an Audio Transcription App with OpenAI Whisper and Streamlit
Building an Audio Transcription App with OpenAI Whisper and Streamlit
Automata Learning Lab
25 Productivity Tracking with Python Short Summary
Productivity Tracking with Python Short Summary
Automata Learning Lab
26 Automating Expense Reports with Python
Automating Expense Reports with Python
Automata Learning Lab
27 ChatGPT, Angry Pandas and AI Code
ChatGPT, Angry Pandas and AI Code
Automata Learning Lab
28 7 Strategies To Learn Anything Using ChatGPT
7 Strategies To Learn Anything Using ChatGPT
Automata Learning Lab
29 Building a Thought Summarization App with Whisper and GPT3
Building a Thought Summarization App with Whisper and GPT3
Automata Learning Lab
30 Visualize a Neural Net Learning Polynomial Functions
Visualize a Neural Net Learning Polynomial Functions
Automata Learning Lab
31 Automating Notion with Python
Automating Notion with Python
Automata Learning Lab
32 Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Automata Learning Lab
33 Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Automata Learning Lab
34 ChatGPT API Released by OpenAI
ChatGPT API Released by OpenAI
Automata Learning Lab
35 ChatGPT API Response Format #machinelearning #ai #datascience
ChatGPT API Response Format #machinelearning #ai #datascience
Automata Learning Lab
36 Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Automata Learning Lab
37 Beyond Diffusion Models with Composer #machinelearning #ai
Beyond Diffusion Models with Composer #machinelearning #ai
Automata Learning Lab
38 Machine Learning for Jiu Jitsu
Machine Learning for Jiu Jitsu
Automata Learning Lab
39 Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Automata Learning Lab
40 Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Automata Learning Lab
41 Visual ChatGPT #machinelearning #ai #artificialintelligence
Visual ChatGPT #machinelearning #ai #artificialintelligence
Automata Learning Lab
42 LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
Automata Learning Lab
43 Summarize Papers with Python and ChatGPT
Summarize Papers with Python and ChatGPT
Automata Learning Lab
44 Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Automata Learning Lab
45 Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Automata Learning Lab
46 Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Automata Learning Lab
47 Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Automata Learning Lab
48 How to Talk to a PDF using LangChain and ChatGPT
How to Talk to a PDF using LangChain and ChatGPT
Automata Learning Lab
49 Query Your Own Notes With LangChain
Query Your Own Notes With LangChain
Automata Learning Lab
50 HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
Automata Learning Lab
51 Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Automata Learning Lab
52 Automating Anki Flashcards with OpenAI and GPT-4
Automating Anki Flashcards with OpenAI and GPT-4
Automata Learning Lab
53 Building A PDF Summarization App with  Gradio and LangChain
Building A PDF Summarization App with Gradio and LangChain
Automata Learning Lab
54 Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Automata Learning Lab
55 DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
Automata Learning Lab
56 LLMs for Research and Planning #artificialintelligence #gpt4 #llms
LLMs for Research and Planning #artificialintelligence #gpt4 #llms
Automata Learning Lab
57 How I Use ChatGPT for Interactive Language Learning
How I Use ChatGPT for Interactive Language Learning
Automata Learning Lab
58 Building an Audio Transcription App with Gradio and Whisper
Building an Audio Transcription App with Gradio and Whisper
Automata Learning Lab
59 Summarizing and Querying Multiple Papers with LangChain
Summarizing and Querying Multiple Papers with LangChain
Automata Learning Lab
60 Mojo - The New AI Programming Language?
Mojo - The New AI Programming Language?
Automata Learning Lab

This video teaches problem solving using Python and Jupyter Notebook, applying George Polya's method to implement and optimize a solution to a programming problem. It covers pseudocode, implementation, and optimization.

Key Takeaways
  1. Ask what the unknown is
  2. Identify the data available
  3. Determine the condition
  4. Break the condition down into smallest parts
  5. Devising a plan
  6. Execute the plan
  7. Review the code and solution
  8. Optimize the code
💡 Breaking down the problem into smallest parts and devising a plan is crucial for effective problem solving

Related AI Lessons

FREE AI Sin City Photo Generator — Turn Any Photo Into High-Contrast Noir Art (2026)
Transform any photo into a Sin City-inspired high-contrast noir art using a free AI generator
Dev.to AI
Google makes Gemini’s personalized image generation free for all US users
Google's Gemini personalized image generation is now free for all US users, allowing them to generate images informed by their Google data
The Next Web AI
Gemini’s personalized AI image generation is now free for U.S. users
Gemini's AI image generation is now free for U.S. users, allowing for personalized images based on user interests and data
TechCrunch AI
WebP's Compression Secret: How a 1MB PNG Becomes a 200KB WebP
Learn how WebP compresses images more efficiently than PNG and JPEG, and why it matters for web development
Dev.to · swift king
Up next
OpenAI Kills Sora then Descends into Chaos
ColdFusion
Watch →