0

Sometimes I feel that I'm too dumb to take this class. Are there any pointers someone could give me on how to approach the problem sets a little better?

I'm currently struggling with the caesar problem set. I try to write down everything in pseudocode first so I have something to follow when I get to my actual code but I'm struggling when I get to that point.

I've watched all the videos and lectures, and they actually make some sense to me, but when I get to writing the actual code, I feel like I don't even know where to begin.

I've looked up help on CS50 Stack Exchange and some of the code to the problem I'm doing is code I've never even seen before. It took me forever to do Mario, but once I figured that out, it only took me about 1 hour to get the greedy.

I guess where I'm getting at is this, if you're good at this, can you tell me a little about how you go about solving problems and how you start to set up your code to write it (i.e. creating variables, functions, etc)?

I appreciate any feed back!

7

I think this is typical specially if this is your first CS/programming course.


Thinking:

You should probably consider these points:

  • you, as a human being, should be able to solve the problem yourself or at least you should have a basic idea of a solution before you try to make the computer solve it.

  • I think problems that can be easily solved by human beings can be typically easily solved by a computer as well, assuming it was given the correct algorithms.

  • you take things for granted that the computer doesn't, so try to be specific as much as possible. you could probably use a strategy like top-down design and step-wise refinement

Here's a way to solve caesar using this approach

Level 0:

encrypt plain text p with caesar cipher using a key k

Level 1:

1. accept k as a command-line argument and validate it
2. prompt the user for p
3. encrypt p and print the encrypted text out 

Level 2:

1. accept k as a command-line argument and validate it
    a. ensure argc stores the correct value
    b. convert k to a number
    c. ensure k is within range
2. prompt the user for p
3. encrypt p
    a. iterate over each character c in p
    b.     if c is an alphabetical character
    c.         // handle c according to the specs
    d.     else
    e.         // handle c according to the specs

So this is one way of thinking. I tried to keep things challenging for you up here to give you room to think. Obviously you could dive as deep as you like.

From my little experience, it takes time and efforts to improve your problem-solving skills. And it gets better and better as you practice. So don't give up!

Feel free to re- watch/read the resources, Google or ask for hints!


Implementation:

You don't memorize the syntax or the available tools/constructs. You just use the available manuals/resources again and again until things become part of your memory. I think this is a valid meaning of "experience".

So given the pseudocode above, suppose I don't know what a command-line argument is, or how to ensure that my program was given the correct number of arguments, etc. Even if these were not issued in the weeks, which they were, I could Google how to do that or ask for hints if Google led me to nowhere, which it rarely does.

So don't be afraid of going back to the weeks or even copying piece of code from there or anywhere else (e.g., a for loop that iterates over a string). More importantly, since you're essentially learning, is to perfectly understand how this code works, why it would fit best, try to optimize it, test it, play with it see if things go wrong and understand why, etc.

| improve this answer | |
  • Thanks Kareem. I really appreciate your advice and input. I'm going to go over Caesar again with this mindset. I think this will help tremendously, not only with Caesar, but how I tackle future problems. – Jzag May 20 '15 at 22:15
  • One thing that really helped me when i started cs50 was that i always play around with C, thinking of a program and trying to code it, giving myself little projects and trying to improve on them. Sometimes i google when i run out of ideas. I found joy in making little programs outside d course. Another thing i do is i normally watch and rewatch every single cs50 video (lectures, walkthrough etc.). The cs50 facebook group too is awesomely packed with colleagues that are willing to help. So goodluck Jzag! – Oluwade Stefan May 22 '15 at 4:04
  • Thanks, Oluwade. I just joined the cs50 Facebook page and I have been Googling a lot on C which has helped. I also found a "study" tab on cs50's website (not through edX) and it has helped a lot. I like your idea of thinking of programs to code on the side. – Jzag May 22 '15 at 12:30
  • Thanks @Kareem and Oluwade. I just got Caesar to work! On to Vigenere. Excited to see how efficient I can work through this one with the mindset you two have helped me establish. Thanks again! – Jzag May 24 '15 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .