## What do you do when you feel stuck?

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 :))

Darina Zheleva
291116

accept rate: 100%

2

(03 Jul '12, 01:29)

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.

Aman Agarwal
1.2k2722

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)

I revise previous chapters..units!

Nagarjuna
4624

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.

Anderson
21

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


Fares Kallaji
655179

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.

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.

Curtis SerVaas
662

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.

Robert Veres
941

I have taken a total of 6 Udacity courses, plus I am currently taking 3 more, and when I finish the Coursera courses I'm taking now, I will have taken a total of 12 courses there (Plus I took a free online course from Caltech, called Learning From Data). So with that said, here is my stragegy (cause believe me, I beat myself over the head so badly on some of the problems I encountered that I almost went into a deep depression at one point and wanted to quit taking all courses for the rest of my life):

1. My first strategy is to look at the "big picture" in terms of learning. After a couple of classes, I sat down one day and asked myself: What is my end-goal? What is it that I plan to do with all this newly acquired knowledge? I asked myself that and tried to get to the very bottom of that question. The rationale behind this is that there will always be problems, tough problems, hard problems, some problems that are even unsolvable. If you decide to become a computer programmer, you will spend 99% of the time debugging and 1% of the time maybe relaxing or having lunch. So if hard problems get you down or demotivate you or whatnot, think about what you want to get out of all of this. My answer was that I want one thing and one thing only: to acquire new knowledge and new skills, at whatever cost! So here is my second strategy, consequently (which might not work for anyone else, but it's working splendidly for me):

2. I take my time. Sometimes, I don't finish homework. Sometimes I don't do quizzes. I chose to go at my own pace no matter what. Sometimes I don't have time to watch a full week's video lectures before the week is over. It doesn't matter to me. My quest is for knowledge and experience, and that - for me anyway - cannot come at the cost of depressing me or making me feel so pressured that I'm not enjoying myself. So far every course that I've taken has gone on to have another "semester" if you want to call it that. If you're too frustrated and it's making you unhappy, the worst case scenario is you quit the course and take it again later when it's offered a second or a third time. I strive for one thing, to understand the material. Sometimes making sure that I understand means that I have to skip a mid-term, cause if I'm not ready to take the mid-term and the due-date is coming up fast, there's no point in me just failing the mid-term, especially if I know I'm not prepared. I will only experience a sense of failure, and that's rarely positive.

Conclusion: So in the rare case that you're like me, just take it easy. Take your time. I read PDFs, blog posts, I go on Stackoverflow, I read Documentation up the wazoo for Python and other programming languages I've started learning (Prof. Norvig says somewhere on his site that we should learn about a half-dozen languages, I will try to find the reference). The point is that I'm in this for the long-haul. I'm in the process of a complete career change. I've been an artist all my life, a painter, a musical composer / sound designer, and an accomplished author. But creativity for the sake of self-expression only has its limitations, for me anyway. I want to build things, I want to solve engineering problems. So every moment that I spend learning something properly from a course at Udacity, that's one moment that I am closer to my end-goal, hence the need, for me anyway, of coming to terms with what my GOAL is in the first place for taking all these courses.

That's my philosophy for Udacity courses right now, if I say so myself. Good luck on your future travels here! :)

Alex Gagnon
89561231

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.

Tim Gibson
3.9k51927

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)

1

Mandatory, yes. But probably the most important part of learining process.

(04 Jul '12, 13:59)

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)

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)

Chaumurky
26314

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

×30,796
×9,101
×2,230
×193
×36
×31
×23