# What do you do when you feel stuck?

 15 3 Probably I'm not the only one that considers some questions challenging. Sometimes, I have an idea how to solve it but not how to write the code. So, I was wondering what do you guys do if you get stuck. Do you get off the computer for awhile? Or look at notes (yours or from the course)? If you look at Google or elsewhere how do you find the stuff you need? Please share if you have any tips and tricks. It will be much appreciated :)) asked 25 Jun '12, 07:56 Darina Zheleva 291●1●1●6 accept rate: 100% 2 Glad you found my answer helpful. Upvote for you! (03 Jul '12, 01:29) Aman Agarwal

 20 Well that's a good question, and I get stuck in the homework a lot too. Normally what I do is, I start writing, on a paper, a rough algorithm of logical steps about how I will go about solving the problem asked in the program. Try to write the algorithm using as many small steps as possible, trust me, it will help in forming a clearer idea. Once you have a clear enough rough algorithm in front of you, try to write down the code you would use for each of the steps. You will realize how much simpler you can make your program and then try it out in the python interpreter. But sometimes when I get a question correct after being totally stuck for a long time, my final program isn't as elegant as the one Dave suggests, but it's still correct. answered 25 Jun '12, 08:38 Aman Agarwal 1.1k●2●5●20 3 And yes, don't run off to Google without having spent at least an hour on working it out. If you get it correct at the end of a long struggle, you will love the feeling much more and it will build confidence. Cheers! (25 Jun '12, 08:43) Aman Agarwal
 0 I revise previous chapters..units! answered 25 Jul '12, 20:52 Nagarjuna 46●2●4
 1 My strategies are: -If I got stuck for more than 20 minutes and nothing comes to my mind, then I take a five minutes walk to breath and relax.It really works in 90% of the cases. -There are situations where even this doesn't work so I stop trying to do it and start to do another thing .Then I only try again that problem the next day, after some sleeping.This is 99% garanty, but sometimes I take some nights of sleep to find the answer when the problem is very very difficult. answered 25 Jul '12, 20:36 Anderson 21
 4 here is what a i do: while True: result = solve_problem() if result: # solution works! break # if it didn't , try again and again and again..... at the end it always works  answered 10 Jul '12, 13:30 Fares Kallaji 465●1●7●9
 0 First I try to go back and look at the sections that taught the material. If that doesn't work, for the unit assignments I briefly look at the answer to get a starting point on the problem and then fill in the blanks. For homework problems, I either sleep on it or get help from looking at similar problems on the internet. answered 10 Jul '12, 10:11
 3 This is a generally useful algorithm for solving problems in life. Write down everything that comes to mind. Basically, start get everything you know on paper. This does not have to be code (but it can be). For example, let's say that I know I have to compare these two elements, I'll probably write "I must compare these two elements, if they are equal, that means, Z and so I should do Y" then I'll write out some basic code and then try to do that for all the individual pieces of the code and then I put them together. answered 09 Jul '12, 14:23 Curtis SerVaas 66●2
 0 I just remind myself that getting stuck is an opportunity to learn. I try to figure out what exactly is tripping me up. Sometimes I realize I just don't remember the name of a function or a method or some detail in syntax. That's usually easy to fix by doing a google search. If it's a test question I might even look up the solution at this point, since by now I know what I'm looking for. One technique I love is to try solve an easier related problem.[1] In the problem where you're asked to print a multiplication table to nxn I felt lost first. So I tried to print one from 1x1 to 1xn first. At which point the solution to the original problem was obvious. For coding specifically, I like to write comments that can be turned into specific code. For example def factorial(n): #calculate n factorial by looping from 1 to n and multiplying #return the factorial of n  Then I might realize that I need to save the result along the way and the final line becomes return result. Basically, I try to break down the problem and solve little chunks until the whole doesn't look so intimidating anymore. [1]This advice is from the mathematician and math educator George Polya. answered 07 Jul '12, 16:02 Robert Veres 79●1
 2 I simply take a short break to refresh myself. Take a walk, read a book, play some video games, do other homework, etc. This also helps to keep you from getting bored from working a little to hard or too long. Also remember, the homework is merely for practice, and is not mandatory. answered 25 Jun '12, 13:01 Tim Gibson 3.9k●5●18●27 1 Yeah, the homework is a bit more difficult than the rest. And some code is actually new (but not in a major way). (27 Jun '12, 19:05) Darina Zheleva 1 Mandatory, yes. But probably the most important part of learining process. (04 Jul '12, 13:59) dd 1 Nothing in this course is mandatory. I actually solve all these problems, including extras, to teach myself programming and successfully pass the exam. If you feel confident that you ace all your homework in this course, but don't have time - skip it, but I would still recommend to do it, because after some homework I feel that my coding skills are sharper than ever (05 Jul '12, 17:14) Oleg Filatov
 1 I step away, do something else, usually sleep on it and leave until tomorrow.. That way something that totally confusing has had time to "incubate" somewhere in the back of my brain. ..So when I come back to the problem later on, its usually clearer. In the intervening time I'll try to read up via other sources, going over and re-enforcing what was covered in the lectures. Repetition forces stuff into the longterm memory. The problem I mostly have, is I might intuitively see how to break a problem down, turning it into steps, but then be endlessly fiddling with the code trying to get it to work.. :( The problem is when you're 75% right, or 99% right.. Sometimes I've just given up completely, and taken a peek at the solution.. Its discouraging if you just can't get the thing to work, after spending an hour on it.. but after seeing that I was almost there in the Solution, but left one step out, its still far more useful than straight-off googling for the problem, because it forced me to think very carefully about the problem first. I'll only use Google as last resort - firstly wrangle with the thing, then leave it or do more reading (docs.python.org also constantly open). If its totally discombobulating, I'll google the steps that seem to be causing the blockage. Then I'll trawl forums here. Failing that, I'll skip and move on to watching the solution video. I think its more important to have tried, and almost got it.. usually its a coding error, rather than understanding or logical implementation. Coding problems will hopefully disappear with more and more practise. I'm also going to find and work through other problems, to supplement the ones on here, to give myself that practice. Oh yeah, "targets" and "rewards".. I'll set a target for the day/week.. If I achieve it, I get a treat! Helps with motivation :o) answered 05 Jul '12, 13:33 Chaumurky 263●1●4
Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

×15,833
×8,445
×1,709
×135
×29
×18
×18