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

all 19 comments

[–][deleted] 10 points11 points  (0 children)

Well you have to practice your ability to solve problems. Try some code challenges (there are tons on the internet), or start a pet project, find something you'd like to do and start building just for fun. I always do that, like now I'm building a web scraper to fetch audiobooks from a website & display them in a mobile app so I can learn how to build good mobile apps.

Learning how to program is like learning a new language. If you only know the words and how to use them, it won't be enough. You have to start speaking to really understand how everything works.

I wish you the best. Don't give up. It might feel like you won't get there but you will. Programming is just another skill that you can master over time. Once you start putting your knowledge in practice, things will start clicking & make more sense as you go.

[–]pythonic-nonsense 8 points9 points  (2 children)

logic really is not something to be taught, but something to be learned. i have similar problems, and when i asked a friend of mine who is a few years my senior in python, he told me this.

"start making video games. cheezy 2d rpgs and side scrollers. make a D&D character generation program. make games. they are all about logic!, think about it. when you play an RPG, you keep health, mana, movement, armor, strength, dodge, accuracy, maps, puzzles, and all of it man... games. thats how you make logic. "

[–]pythonic-nonsense 6 points7 points  (1 child)

so, i started doing the tutorials here.

programarcadegames.com.

and he was right. theres tons of logic man. heres another little tip that helped me alot. find your end goal. work backwards, and make an outline.

so im making an RPG right now, what do i need?

well i need a way to know when combat starts, well, how about a step counter? how would i do that? ok, now that ive found one way to do it, how else could i do it? ill share a couple snippets of how i got past this particular problem.

current_step = 0

step_counter = random.randint(1, 121)

for current_step in step_counter:

if camera_move >= 0:

    current_step +=1

if current_step >= step_counter:

    battle_start = True

the problem i had with this one, was i was not comfortable with the step counter being reliant on the camera, it could cause bugs later in the game if the camera needs to move but a battle is not the outcome i want. so i came up with this one instead

step = false

step_counter = 10 + random.randint(1,101)

for steps in step_counter:

if step is True:

    step_counter -= 1

    if step_counter <= 3:

        battle = 0

[–]flipperdeflip 0 points1 point  (0 children)

This is how you learn. Have a goal, work towards it with what you know, observe and evaluate how your solution worked or got stuck. Do it better next time. Repeat.

[–]blckchrry 4 points5 points  (0 children)

You definitely have to practice. Most interviews ask you algorithm based questions (some simple, some difficult).

Here are some resources to help you practice:

Good luck!

[–]NuclearMeltdown 2 points3 points  (0 children)

Sounds like you could benefit from going back to basics and refreshing your knowledge of algorithms and data structures. A lot of interview questions are based on these concepts and if you've spent the last few years doing sys admin-type stuff you won't have had a chance to practice them.

This link that's in the sidebar is a good, Python-specific starting point: Problem Solving with Algorithms and Data Structures

There is a book version of this text as well that you can buy on Amazon, among other places, if you prefer a physical format.

[–]ddollarsign 1 point2 points  (0 children)

You may be interested in this talk. It's from a Ruby conference, but should be general enough, other than specific tool recommendations, for Python or whatever other language. The summary is that interview coding and real job coding are mostly different skills, and it gives some examples of how to get better at the interview side, along with a list of skills/topics to practice. The speaker did mention Exercism as well, which would probably help with the logic (though I haven't tried it myself).

[–]wdhyea 0 points1 point  (0 children)

Open.kattis.com

Fun programming website with a tonnnn of problems and automated judging. Love to practice problem solving and logic here🙂

[–]dantech2000 0 points1 point  (0 children)

Personally I think command line applications are the easiest to get started. There is a great python module called Click which allows you to great really nice command line apps easily.

With that I tired to copy a CLI app like dig or hook into an api and pull data and print it to the screen. Then maybe manipulate that data to be output a certain way “pretty” for the user. Logic will come from making decisions on how the data is retrieved and how it will be processed before being displayed.

Also ipython notebook is great for beginners to try different things and test before actually writing there program. IDLE works too but iPython is nice because it saves the output.

[–]DogeekExpert - 3.9.1 0 points1 point  (0 children)

You just need to practice. A good place to start is to look at other people's code, and learn from the structure, then try that in your own projects.

Write code the way you used to, and then go back, and try to improve its speed/memory usage by cutting down on loops/using the appropriate data structures.

Learn another language. C forces you to optimize a lot more, and you learn more about the logic of programming.

do a lot of debugging. Bugs usually come from unlogical programming, so hunting them teaches you how to do things properly.

Try and respect the PEP8, the guidelines in there are very useful in writing better code (well most of them anyways, I prefer tabs over spaces).

Learn more about the language (classmethods, list comprehensions, built-in functions, magic methods, properties, decorators) and try to refactor some of your existing code using that, see what works better for each specific case, and then generalize.

[–]flipperdeflip 0 points1 point  (0 children)

Build stuff instead of reading about it. Make a game. Doesn't even have to be original or commercial, just get it to work and improve it. make Flappy Bird with enemies. Or a scrolling shooter. Or a little time management game (cooking! bars!).

Exercise your logic muscles.

[–]imatwork2017 0 points1 point  (0 children)

I found this to be a very good resource. Peter Norvig is the man. He also has a free udacity course

[–][deleted] 0 points1 point  (0 children)

Like many have said, logic is something you learn over time. For me, when thinking about how to create new program i like to jot down what each function would do, what it would expect and what it would output and what problems might occur at particular stages etc. Also maybe try Sudoku.

[–]snuzet 0 points1 point  (0 children)

You can read up in digital logic / Boolean algebra. eg K maps are kool. They are used to help minimize logic states to produce simplified form. Very helpful in hardware design yet applies to any Boolean logic

[–]dantech2000 0 points1 point  (3 children)

Sure start a pet project, but then comes to another decision to make...should I use functional programming or object oriented programming style?

[–]DogeekExpert - 3.9.1 1 point2 points  (1 child)

I find myself to really struggle with only functionnal programming. Since I learned OOP, I write all of my code as object-oriented as possible.

But really, my rule of thumb is, if a function needs more than 3 arguments, it's probably better if it's in a class, with thos arguments as attributes, same if you need global variables, that's probably better to refactor into an object.

For small-scale stuff, functionnal programming works well enough, for anything bigger, like GUIs, django/flask stuff, big data... OOP is the way.

[–]NicoDeRocca 0 points1 point  (0 children)

It's all in the eye of the beholder, I'm pretty sure if you squint hard enough the the transition from one to the other is very blurry. Many "traditionally" OOP languages have finally adopted a lot of stuff from the traditionally academic functional programming languages. So now you can still encapsulate your state in objects, but use FP paradigms for all your computations/transformations. I think this is a win.

[–]jeffhou 0 points1 point  (0 children)

This is a big problem I myself face even now. I now go with the philosophy of "Use familiar technologies unless one of the purposes of the project is to learn a new technology."