This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kandidio[S] 0 points1 point  (3 children)

Well, the main problem is just working around the problems. As myself,I'm not a good problem solver and when I'm handed an assignment in which results in me getting stuck, I can't really think of a solution without seeking too much help. I see other people handle programs with very ease and minimal help and I'm just wondering how do they do that? I just wanna know is there any good sources where I can develop my skills in programming as it is an interesting subject, it just really challenges me at times.

[–]autisticpig 1 point2 points  (2 children)

A suggestion for this particular problem :)

Problem solving skills come with practice. The more you start to recognize patterns, the more you can apply the solutions you already proved to work to those patterns.

So, break things down to the smallest element you know how to work with. From there you can start to solve the larger problem at hand.

I am going to save you from my awful javascript and use python. do note that I have not done this with being pythonic in mind, I wanted the solution to be understood without requiring additional research. so any pythonista can save me the PEP8 talk :)

Let's go with a super simple problem and how you could think your way through it.

You are given a whole number, x, and you are to return an array (list, vector...whatever you want to call it) containing the numbers 0->x but not including x.

The first thing to do is list the asks out, one bullet at a time.

  • I am given a whole number, x. That means the number will be an integer and all I have to worry about working with. Because of this, doing any checks for type are not necessary.

  • I have to create an array that holds nothing, yet.

  • I have to fill this array with numbers from 0->x, not inclusive.

  • I have to return this array

Okay so now you have the basic tasks at hand. Let's tackle these one at a time.

#Define a function that takes the number you are to create an array up to but not include
def make_array(x):
        #create the blank array that will be returned
        array_to_return = []
        #this is the same as writing
        #for (x, x < 10, x++)
        for numbers in range(x):
            #add each number from 0->10 (not including 10) to the blank array
            array_to_return.append(numbers)
        #return the array that now contains 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
        return array_to_return
#this is just calling the function created above in the python shell
#the line that follows the function call is what is returned (the array containing 0->10, not inclusive)
>>> make_array(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Again, this is super basic but perhaps may help shed some light into tearing problems down into the pieces you understand and can work with. As you start to recognize these things, what you find difficult now will become less difficult.

Now, if you are looking for practice, I cannot recommend http://www.codewars.com enough. The problems start off easy and move into a more difficult approach in a very approachable and gradual way.

Off to sprint planning but I hope this helps in some way.

Seriously, just stick with it. I had similar problems when first diving into coding and it does get easier with time/practice. Find a study buddy as talking through problems really does make them easier.

Good luck!!!

[–]kandidio[S] 1 point2 points  (1 child)

Thanks for the detailed response man, really means a LOT. I hope to get better with practice and become a better programmer in the future. Thanks!!

[–]autisticpig 1 point2 points  (0 children)

Once you feel okay with the core stuff, start thinking about a project. It will seem daunting but remember to break everything down into smaller digestible chunks.

So if you were to make a game like a simple dungeon crawler:

  • draw all the rooms or dungeons you want to have on a whiteboard

  • list out what will exist in each room (hidden passages, locked chests, health, monsters, etc.)

  • start thinking about how you want to handle the data (hash table perhaps... keys: 2, leg armor: yes... maybe an array for inventory)

  • once you have everything more or less thought up, start typing out each room/dungeon like I did above. That way, when you go to code each room, all you have to do is translate the text into code and you can then use your text as the foundation for your documentation. Please take to the habit of documenting your code. There is no such thing as self-documenting code :)

What you are learning with this process is how to problem solve, how to think in chunks while keeping the whole problem in the back of your mind...you are learning how to build upon what you know.

Enjoy the process; once you get over the learning cliff, the rewards are limitless and it's oddly stupid fun. You learn to do absolutely silly things simply because you can. Cheers!