How To Think And Problem Solve In Coding

How To Think And Problem Solve In Coding

– [Qazi] Hey you, what is up? How’s it going? This is Qazi from, also known as Papa Python. Today I want to talk
to you about the power of how to think and solve
problems effectively. Alright, I wanna talk to you about how to think about code, how
you actually go about dealing with problems. One of the things that I
see with a lot of people that are starting out with
code, who are beginners, I was actually just on a call for my Profitable Shortcut program, it’s a group coaching
program and we have lots of students in there and we
have questions like these, it’s like, how do I improve in coding, I feel like I’m stuck. Either they find that
they’re in this tutorial purgatory where they’ll
spend a year learning something only to then forget it, and then, do it again,
and again, and again. And they never feel like it sticks or that they understand it. I made a video, oh by the
way this also day four of my video challenge,
so I’m doing a 30 days of videos, one video a day. So if you wanna do some kinda challenge do it with me and you can
also follow me on Instagram, CLEVERQUAZI, and I am a lot
more active on my Instagram and you can also follow me along and see everything that I’m doing including the challenges and my routine. But, back to the video. So how do you think about
your problems effectively and how do you actually improve? So in my previous video, I talked about what are the effective
tips to learn how to code? Alright, and that was also really amazing, I’m gonna pop that up right here. But, in this video I
wanna talk to you about how can you actually think
about solving problems. So let’s say you have
some kind of problem. What do most people do, they
just start writing code, especially beginners. They just start writing code and they try and see if something works,
if something doesn’t work, they just write more
code, print more stuff. But they’re thinking about the program very, very linearly. It’s this one thing. So, let’s say you have to make, I’m gonna use a simple example,
let’s say you have to make a Tic-Tac-Toe game. If they have to make a Tic-Tac-Toe game, they’ll just start writing
it and they will think of everything as just one thing. So this includes, you know, they’ll think of the diagonals and
the columns and the rows and all that as one thing and they start coding something up. But, what you actually
need to do before you start on a project like that is,
use frickin’ whiteboard. Whiteboards are awesome,
so get a whiteboard if you don’t have one, invest in one, it’s one of the best
investments you can make. But, if you don’t have a whiteboard just use a piece of
paper or something, okay? But you want to think about this problem and coding is thinking and I feel that sometimes people forget that. When they’re following tutorials,
they’re just typing stuff and following along, they’re not actually, actively thinking. When they are trying to solve a problem, they’re just like typing stuff, running it in the terminal
and see if it works. But, if you wanna go
about solving a problem you need to think about it. So, if I have to solve a problem like the Tic-Tac-Toe, right? I’m gonna be thinking about, I’m gonna break it up
into different components. So Tic-Tac-Toe, first of all, Tic-Tac-Toe I have to come up with a representation of the grid, of the board. So first I’m gonna be like, okay, first, the thing I’m gonna have to do is actually create a board, right? A three by three board. So you know, that might be
like this type of board, okay? And whatever, for now, I’m
just gonna have all X’s in there or all zeroes
or ones, doesn’t matter. But first I have to represent this, this is my first problem. Then my second thing is that
how do you detect a win? So I need to be able to detect a win. So what are some ways
you can detect a win? Well, okay. I can detect a win based
on rows, so if you have all three in a row you can win, right? And you have to check consecutively. Then I have to detect a win on the columns and then I have to detect
win on the diagonals. So that means that I’m
gonna create like a function and I’ll have one function
that’ll just be called like check rows. Pretty simple, right? So I’ll write one function
and all that functions job is to check the rows. That’s it. So what I’m doing is I’m
taking this giant problem and breaking it into its component parts. Taking this giant problem. It’s almost like how
do you eat an elephant? How do you eat an elephant? You eat an elephant
very slowly in one bite at a time and over the course
of days, weeks and months. I never ate elephant but I
assume that’s how you eat one. Probably can’t eat one in one sitting. Most people code like
they’re trying to eat the elephant in one sitting. It’s not gonna happen. You have to break it down. You have to understand all
of the component problems that one problem has, right? It’s a layer of problems. So I want to be able to check the rows, then I want to create a
function called check columns, alright, and then I’ll create
a function called check diags. So now I’ll have three
different functions. One function can check a row and tell you whether there’s a win,
somebody has won or not. Then we have a function
called check columns and that can detect if
somebody has won on the columns or not, then we can have
check diags that can check if somebody’s won on the diagonal or not. And then we can have something called check win, alright? So we have all these functions. The check win function,
well all this can be, it can just be comprised of
all three of these functions, right? Because you can just run
check win and then it will run check rows, check
columns, check diags, and it will run all
three of these functions until it finds a win, alright? So right now we’re just trying
to think at a high level. We’re not trying to get too
bogged down in the coding details of how it’s gonna
work, what data structure we’re using, we’re
trying not to think about all those things. We’re just trying to think at
a high level of this problem and try to solve it in
these basic components. Eventually you’ll have this to-do-list and then all you do then,
then the part is easy, you write code, you do research, you figure out technically, but now you have a big goal of
what you actually need to do. Because otherwise most
of the people, you know, are coding blindly. I have all these
functions that can tell me if a win took place, right? And then I have functions
that can determine a loss, we can have a
function that can detect whose turn it is. Or whether it’s nobody’s turn, right? So we need some states
as well, for this board. We need to have a state where it tells us whether the game is still playing so for example, we can
have a still in play or we can have a state that says you know, game over, so I’m meaning somebody won. So what this would do is if
we have a while loop, right? And we’re running this game
over and over and over again, then it would be in this state, it would always check if
the game is still in play, but if the game is not still in play and somebody has won and
somebody has connected all three in their rows,
columns, and diags, it will change the state
of the game to game over. And then it’ll stop the game, right? And then a new game
might start after that. The point is not to solve this Tic-Tac-Toe problem right
here, right now, but my point is to get you to actually think at a higher level about
your coding problems. You need to break them
down into components and in the start it’s gonna
require you to understand it in English or whatever
language is you know, your mother tongue, but first you’re gonna actually need to understand
the problem in English and be able to describe it,
visually have it somewhere, then you need to break it
down into its component parts and know exactly
what you need to do. So first I will say understand in English. Two, break it down, okay. So you want to break the problem down into its component parts, that
way you know exactly what it is you need to do and then
you have a plan of action. So after this once you’ve broken it down, you know, you have a plan of action. And then it’s simply about
what order you want to do this in, what it’s gonna be. Are you gonna make check rows first, are you gonna make check win first? Are you gonna make check diags first? Or are you gonna make 3-D
board representation first? So it all is gonna be about you know, what your plan of action
is, and then once you get inside of a function, that’s
when you start needing to worry about what data
structure you’ll be using, how you’ll be actually making it happen. You know, for example,
are you going to be using a dictionary or are you gonna
be using a list of lists to demonstrate a 2-D board, okay? So that, those are the
things that you’re gonna need to think about later. So hopefully this video
has helped you or at least reminded you about some of the things you might have already
known, but I encourage you you know, again to do a
daily challenge with me because I’m doing a video challenge, you can do a thirty
minute or twenty minute video challenge with me. So I’m on day four of this,
so you can start tomorrow or the day after and
just go with me in this. With that said, I hope
this was helpful for you. Thank you so much for
watching and leave a comment on how you think you
can apply this, alright? I’m now being very engaged on my platform, on Youtube as well, so
I’m responding to a lot of people, but if you
really want to be able to get in touch with me or
you want to see my routine and behind the scenes
so you can be inspired. Or pick up a lot of tactics
and strategies from me, definitely follow me on Instagram because I am really really active there. I’m putting stuff there every single day so you can see a lot of
behind the scenes stuff. Alright, thank you so much for watching, as always, I love your
face and I’ll see you in the next video. Yo guys, just finished video
four day four challenge, got my setup right here, we
talked about lots of cool stuff, let’s keep going for
thirty days and if you have something you want to be
accountable for, hit me up or just do it, it’s gonna be fun. Alright, peace. (upbeat outro music)

82 thoughts to “How To Think And Problem Solve In Coding”

  1. I really like the efforts you put in your videos all of them coming one day after another
    Give this man a thumbs up !!!!

  2. I just started the MIT intro to python mooc and this is so what I needed! I feel ready to try again in week 2. Thanks for posting.

  3. I love the new glasses dude. Been watching your show for 6 months and you’ve been a big inspiration for me

  4. Wow! That was great. I have been avoiding the problem solving part of Python just concentrating on the syntax. It will be great to go to the next level. Thank you for both the motivation and the method I can use to achieve my goal.

  5. Thank you sir. This video is really helpful for me. Because my logical thinking to solve problems is not good and I was not knowing how to figure out this problem. After watching your video I know that thinking logical is important, solving problems is important, actually I was just focusing on syntax but not actual coding .thanking I know my problem now. And I will improve it.

  6. i`m developer (no degree) and i want to move for usa, witch city is the best to start my career? i think i cant pay for apartment in california. i will move with 10.000 dollars (only me) without job. can someone help me?

  7. I've actually done it in C code the hard way where I did not know the C string library and functions existed! plus I've done it with multiple "if"' ' s all in before 2008

  8. Some peoples are trying to tic tac toe solve as you have shown and they again stuck in solve the problem.

  9. Dude! I've been wanting to say this , you are an inspiration and your videos are so realistic !
    I've seen so many tech videos, but yours never disappoint,
    Also I heard about your story, how you battled through so many difficulties. An absolute inspiration for me personally! Thank you so much.

  10. Interesting video but I have a question. I like the fact that you broke the tic tac toe game down to I guess you call them user stories (or at least that is what free code camp calls them). My personal problem is taking that user story and turning it into code. Any ideas on tutorials on that?

  11. Thank you. I have been having some trouble at the end of the course I am doing because I kept looking at the problem and just jumping at it all at once just typing out stuff over and over getting frustrated. Now I know to develop my problem solving skills. thank you for the advice!

  12. Thank you so much! This was really helpful. I definitely need to slow down when approaching a problem and break each part down – I will definitely be getting a white board!

  13. totally shit u are telling about project that how to solve…………………totally shit and time wastage

  14. Very good video. I'm impressed by the way how you explained the topic. This tips will definitely help me a lot. Thank you!

  15. Makes zero sense to me, I’m guessing this is why I started a clothing brand instead because everything you just said made absolutely no sense to me.

  16. Hi, Qazi I learn C, C++ but when I solve a big coding problem then I am not able to write code properly. If I write code then it will not run properly or something bad happen. How I overcome this problem.

  17. Liked the video but I guess general thing that might help you out in long run, it took 1:40minutes to actually get to topic. Which makes a lot of people leave the video before the video really begins

Leave a Reply

Your email address will not be published. Required fields are marked *