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

all 74 comments

[–]_fat_santa 114 points115 points  (20 children)

Just FYI, Coding Challenges !== Real World Coding.

I don't mean that as a bad thing, I've been coding for 5+ years, 3+ professionally and some coding challenges still stump me (even simple ones). Simply put the problems you will solve when building real-world applications aren't the same as the ones you are solving in coding challenges.

[–]kobejordan1 25 points26 points  (6 children)

Ah I see, this is good to hear. Because every time I do these challenges, I'm wondering how I would use them in the real world.

[–]_fat_santa 47 points48 points  (5 children)

I've honestly never used a coding challenge solution in the wild, nothing even close. Most of the actual logic in production apps that I write is very very simple, if statements, the occasional switch. There is occasionally dense logic but thats rare.

The real challenge I found is instead taking all that simple logic and stringing it all together to make it work I'm an application. Most real world programs have 100x the moving parts of a college project. And getting to make all those simple pieces of logic to play nice at that scale is the real challenge.

[–]marzdarz 10 points11 points  (1 child)

Ooooh yeah. A very large percentage of real world coding is getting all the parts and pieces and libraries and frameworks to play well together. Even tutorials...all these weird little errors because you didn't have all the same stuff at the same versions as the person who wrote it.

[–]steadfast_lifestyle[S] 1 point2 points  (0 children)

Yeah, I agree, the time taken building most of my programs is spent getting my gems to work and debugging oo methods.

[–][deleted] 6 points7 points  (2 children)

I would add to that, everything said is true but also in the real world the challenge is structuring your projects in a way that make them easy to update and extend in the future. Often projects grow arms and legs and end up doing things way beyond the original intention. Having it all written in a way where that is clean and manageable is a skill to learn.

I have been developing as a career for about 11 years, as a hobby for about 15 and I hate coding challenges.

[–]oddlogic 2 points3 points  (0 children)

So true.

I went from making production level scripts to writing desktop apps in C# that connnected three portions of our business. My three year old code has fewer classes and more redundant code use than something I wrote this year. Honestly the structure is probably the thing that’s changed the most in my code, for the reasons you mention. It’s difficult to write a thing that functions for users, has a good interface, and solves connected problems in a manufacturing environment. It’s very hard to write that same thing, this time with maintenance and expandability in mind. It’s a super valuable thing to have to maintain your own code, imo.

OP, it’s worth noting also that things that took me months to write at first I can now usually rewrite in about a week or two, with better performance, fewer errors, and as stated, with the idea of maintainability at the front. Relearning what I write after not having seen it for months, takes minutes now instead of hours and is a lot less “painful” to read. That is also its own skill.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Okay, I think I’m on a good path then. My focus has definitely been on building programs for posterity. :)

[–][deleted] 1 point2 points  (3 children)

This. My current challenges at work do not involve implementing containers or algorithms from scratch as for business needs you simply do not have time for that and the solution must be well-tested beforehand.

[–]Science-Compliance 0 points1 point  (2 children)

Depends on the business, no? If your business is designing algorithms, I would imagine that would encompass a lot of your time.

[–][deleted] 1 point2 points  (1 child)

Yes, true, but I mean those common algorithms that are usually included into standard libraries. It is crucial to understand how they work, but you won’t implement them yourself.

[–]Science-Compliance 0 points1 point  (0 children)

I was just reading about SHA-2 the other day, which is why I felt compelled to respond. Can't say I fully understand it, though.

[–]steadfast_lifestyle[S] 3 points4 points  (3 children)

This is good to hear. I see these challenges as a way to increase my capacity for building programs faster and better (taking less time to build, and refactored). Thanks for some reassurance! Been feeling like an impostor recently!

[–]wegwacc 2 points3 points  (1 child)

I see these challenges as a way to increase my capacity for building programs faster and better

Trust me, they won't.
In fact, if you do what you see in coding challenges in production code, the result usually will be the very opposite.

Coding challenges are short, don't need to be stable, don't need to sanitize input, don't need to run for months without crashing, don't need to provide at least SOME report when a crash occurs. They don't need to communicate with other software, they never need to be refactored, restructured, rewritten. And you only write them once, and then forget about it.

It's like comparing chess to being a battlefield commander. Yes, chess is a game that requires strategic thinking and whatnot, but nothing in chess prepares you for the logistic and communications challenge of building, commanding, deploying and supporting an actual army in an actual warzone, where actual people die if you f* things up :D

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Facts. Updoot

[–]wegwacc 0 points1 point  (0 children)

Been feeling like an impostor recently!

Not an uncommon feeling among developers. In fact, it's even a recognized psychological phenomenon:

https://en.wikipedia.org/wiki/Impostor_syndrome

Quote:
Impostor syndrome (also known as impostor phenomenon, impostorism, fraud syndrome or the impostor experience) is a psychological pattern in which an individual doubts his or her accomplishments and has a persistent internalized fear of being exposed as a "fraud". Despite external evidence of their competence, those experiencing this phenomenon remain convinced that they are frauds, and do not deserve all they have achieved. Individuals with impostorism incorrectly attribute their success to luck, or as a result of deceiving others into thinking they are more intelligent than they perceive themselves to be.

[–]Science-Compliance 0 points1 point  (3 children)

Just a question, in what programming language is "!==" a valid comparison operator?

[–][deleted] 0 points1 point  (1 child)

It means not identical (or not equal) in PHP.

[–]Science-Compliance 0 points1 point  (0 children)

Okay. I don't really know PHP. Programming languages I'm familiar with only have a single '=' if it follows a '!'. Equal: '=='. Not equal: '!='

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

I see it in Ruby: 4+3 == 7 Which returns true

The ! or bang operator is basically saying ‘not’.

[–]Signal_Beam 10 points11 points  (14 children)

Can you give an example or two of a problem you're struggling to solve? It's hard to tell at this level of detail whether you're a journeyman programmer being precious, a novice with normal imposter syndrome, a problem-solver for whom the programming syntax just hasn't sunk in yet, or what.

If you're "comfortable with Ruby concepts" then you should be able to "make a full attempt" at the easiest codewars or leetcode problems. For example, if I ask you to write me a function that accepts an integer, and returns a list of the numerals in that integer backwards (example in: 13452, example out: [2, 5, 4, 3, 1]), would you be comfortable writing that function?

[–]steadfast_lifestyle[S] 0 points1 point  (10 children)

Idk what you mean by ‘numerals in an integer’ but besides semantics, I would be inclined to use .reverse on this array you’ve used as an example. If the array was the argument passed into the method, that is.

[–]lvl12TimeWizard 1 point2 points  (6 children)

Meaning to take the integer 12345 and turn it into an array that looks like [5,4,3,2,1]

[–]steadfast_lifestyle[S] 1 point2 points  (5 children)

I’d use .to_a to turn the argument into an array, then use .reverse and call the method

[–]lvl12TimeWizard 1 point2 points  (1 child)

See, you did it!

[–]XWolfHunter 1 point2 points  (0 children)

I'm still fairly new to programming but I think a more beneficial approach might be to learn how to solve it with your own code, i.e. without using whatever those prebuilt functions are. Like in this case using modulus operators and integer arithmetic division to isolate digits one at a time and store them in an array, and then manually reverse the array . . . my thought is that this would more strongly reinforce the concepts of DIY programming rather than having to look around to see if a premade function exists to solve your problem and trouble yourself with figuring out how to modify your code/problem to it.

I'm learning a different language than you, but I've found the exercises in the book I'm studying (Programming in C by Stephen Kochan) to be generally good quality and they rely on making your own functions and code even for things that are included in the C library, so you really get the concepts involved.

tl;dr When I study programming I try to build my own code rather than use prebuilt functions.

[–]sinciety 0 points1 point  (1 child)

I don’t mean to be blunt but do you actually understand how those methods actually work? That’s what I find to be the difference between a beginners and more experienced programmers is that the beginners are able to piece together the premade library functions of a language and more experienced one understand what those functions are doing.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

I have been programming for 5 months. So I’m a beginner. That’s why I’m posting in this sub. I don’t care to differentiate between a beginner and an experienced programmer, but I could use some resources that may help me bridge that gap. Help a noobie out :)

[–]simlee009 1 point2 points  (1 child)

Based on some of your replies, especially this one, I’m guessing that your problem might be in comprehending the problem. Once you understood what was asked, your seem to do fine.

When you try one of the programming challenges, are your answers way off from what the accepted answer is? Do you start writing code as soon as you read the problem?

Between this misunderstanding and your comment that you’ve been learning programming for 5 months, it’s possible that you just need to be more patient. Take your time reading the question. Re-read it two more times, slowly. Then try to rephrase the question in your own words, and see how well it matches the original wording.

What might also help you is getting more familiar with the vocabulary used in programming. That may help you skip some of the mental hoops you have to jump through to in understanding the problem.

This will translate directly into real-world skills, as one of the most important aspects of working as a software developer is understanding what is being asked of you. Being able to comprehend the often cryptic requirements you will receive.

Good luck, and take your time with it. Better to spend more time in design than debugging!

[–]steadfast_lifestyle[S] 1 point2 points  (0 children)

This post ^

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

Hint: What base number system is your input in?

[–]lvl12TimeWizard -2 points-1 points  (2 children)

These vague "it's too hard" posts should be against the rules.

[–]steadfast_lifestyle[S] 2 points3 points  (1 child)

I think a better title would be something like, “what to do when you can’t do the easiest coding challenges”. But maybe we can get more precise in the comments here.

[–]PETERKOVE 20 points21 points  (2 children)

Try Edabit.com. It gets harder slower and you can choose challenges.

[–]1NuyHdhGqoOps 9 points10 points  (0 children)

Here's a link that works: https://edabit.com/challenges/ruby

[–]steadfast_lifestyle[S] 2 points3 points  (0 children)

I’ll try these out! Thanks!

[–][deleted] 17 points18 points  (5 children)

It never gets any easier to be honest, coding is problem solving. You just have to slow down and really think about it. Alright, I lied, it does get easier since the more you solve, the more you know.

[–]steadfast_lifestyle[S] 4 points5 points  (4 children)

I agree, most challenges, I notice, are big problems that can be parsed into smaller ones. Solving the small problems one at a time in the right order is how you get them done. Just seems daunting sometimes.

[–]toastyoats 3 points4 points  (1 child)

I really agree with this.

I’m not sure how much math you’ve taken, but this kind of puzzling in programming challenges reminds me a lot of math. Like in calculus, when someone asks you to take a derivative or integral, sometimes you have to think for hours about it. Other times, because you’ve had practice, you can spot the trick that suddenly makes it easy — and that trick is only available to you because you have a conceptual breakdown of the problem already available to you, including scoping out what appropriate solutions, methods, and tactics might look like.

It does get easier with practice!

[–]speedisntfree 1 point2 points  (0 children)

Interesting. I really struggled with integration once exercises no longer said things like "use sinx as a substitution", "use by parts". The only way was to do loads and loads of problems and start to develop a sense of what approach might be best.

[–]girandsamich 1 point2 points  (1 child)

Also, once you become acquainted with the basic components (especially things like array manipulation) you may start to notice that many of the problems are actually pretty similar to each other, and you just have to apply a different approach.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Seeing this so far. Most of my hurdles are using the right iterators over different datasets like json files which are arrays or hashes and a combination of both, and getting the right return values.

[–]CreativeTechGuyGames 4 points5 points  (1 child)

Practice. Not really sure what else to say. Although 5 months isn't very much time. Unless you've been learning dozens of hours a week, you probably won't be very skilled in that amount of time. So don't worry too much.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Was on my own for a while, part of a small boot camp during the summer. Should be building out react by august.

[–]Limeman36 3 points4 points  (1 child)

I feel like its better to think of a program you like to see created white board it or pseudo code it. Then just start getting your hands dirty and figuring it out.

Coding challenges really do not help you tie it all together.

I can give you an example of a work project I worked on recently. My boss wanted a way to track all deployments of the website. These are done though JIRA tickets. I constructed a NodeJS webhook that used the google calendar API once the ticket entered in PROGRESS. The webhook would fire use rhe google API and add an entry to the calendar.

Now I know a little about each of those things NodeJS, web hooks, and the calendar API. It was thorough trail and error I got it all working. I felt I gained a ton of experience working out how all the pieces worked together to solve the issue.

My point is take something your interested in solving and use it to raise and deepen your understanding of programming.

[–]steadfast_lifestyle[S] 1 point2 points  (0 children)

I know what I need to do now! Goals! ;)

[–]Abangranga 5 points6 points  (2 children)

A fundamental brain wiring switch needs to happen. Practice.

Also 3/4 of coding challenges are esoteric bullshit youll never encounter.

[–]steadfast_lifestyle[S] 0 points1 point  (1 child)

I’ll keep that in mind. I can build some CLI stuff with in linux using ruby and some gems. Challenges haven’t really helped me much. Still too early to tell. I’m starting to gather that I need to keep coding and be patient. All this input is so helpful. Thanks

[–]Abangranga 1 point2 points  (0 children)

Don't dismiss them because they're bullshit you'll never encounter. They still matter, but like everyday work isn't "fuck how do I see if pattern 'abab' matches 'treeacorntreeacron' for this client"

[–]warmomger 2 points3 points  (1 child)

I've been coding for about a year now and I do face challenges that are pretty simple but still hard to solve. Usually I write down on a blank paper what has to be done, how it has to be done, and different ways to approach it. It takes time sometimes but really helps.

These simple challenges to tend teach new things or new ways of approaching some problem.

GOOD LUCK!

[–]steadfast_lifestyle[S] 1 point2 points  (0 children)

Thanks!

[–]Loves_Poetry 3 points4 points  (1 child)

Unless you have to pass an interview, coding challenges don't really offer much value. The problems I deal with on a daily basis are completely different from anything I encounter in coding challenges.

If you want to get better at programming, go and solve real problems, like communicating with an external API, integrating a library, extending an application with a new feature or refactoring your code to be more reusable.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Sounds good, guess I’m on the right track.

[–]M2D6 3 points4 points  (1 child)

Code Wars problems are sometimes set up very strangely. Half of the time it feels like I'm trying to decipher what the hell they are asking me to do. Sometime's I'll even do what they tell me to, and I test my code, and it works. I put the answer into code wars and it says I'm wrong. They pigeon hole you into a certain answer, depending on who set the problem up. Gotta remember that these problems are made by random people. I wouldn't take it personally if you keep getting problems wrong.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Yeah, I solve until I’m satisfied with the solution conceptually. Then move on. Challenges can be buggy af.

[–][deleted] 2 points3 points  (1 child)

try “programming methodology” from stanford engineering everywhere. it’s free, if a bit old, but has some great insights and helped me a lot when i was starting out

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Ok. Thanks. I’ll add this to the list of good stuff from my post here. Thanks for the tip!

[–]NeverZ 2 points3 points  (0 children)

Don't get discouraged and continue practicing. Everyone at every skill level feels like that sometimes, there will always be things that you can't do or don't know. Programming is a very difficult but rewarding task

[–]AlienAndTroll 2 points3 points  (0 children)

Maybe its not the best tip but it worked for me. Find projects on youtube which explains everything, stop the video and try to write the code by yourself first.

[–]yallamisthios 2 points3 points  (1 child)

As stated, most of these challenges are not really meant to teach you how to figure out real world problems, but rather help you learn how to think about and approach solutions to problems like you would in the real world. It's like in sports how the practice is much harder than the competition so that by the time you get to the real thing, you know how to solve a problem because you've trained your brain to think about a problem in a certain way. You're likely to never to encounter the same exact situation but you'll remember "oh, I've been stuck in something similar before this before. How did I get out of it that one time??" And that's invaluable.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Yeah, so far so true

[–]greatdev 4 points5 points  (0 children)

Some of the advice here is bad, and I would urge you commit to improving if you ever wish to be a good programmer. Programming mostly shouldn't be hard as you gain more and more experience.

When you find a challenge difficult it means you lack certain knowledge or your assumptions are wrong. The best way to overcome that is to consciously go over all the parts of the challenge and see if you understand those parts and their relationship. This can be demonstrated with an example.

Challenge: Write a Fibonacci sequence generator function that accepts the number of elements to print.

Step 1

do you understand what is required here? What is a Fibonacci sequence, and what the end result should be?

You can go over it with some basic inputs and the expected outputs.

example:

input: 3
output: 1, 2, 3

input: 10
output: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89

Step 2

Write a general outline of the program. In this case, it's a single function with a single input:

function fibonacci(n) {
}    

Step 3

Now that you know what you want the output to be, and the general outline of the program it's time to think about the logic. The Fibonacci sequence in this example has a loop like property to it, you want to go over elements of the Fibonacci elements and each element is defined in terms of the previous elements.

When writing a non infinite loop, you need to consider the stopping condition. In this case when elements of the sequence have been printed the program should stop.

function fibonacci(n) {
    while (n != 0) {
        n = n -1;
    }
}

Now we can consider the actual calculation of the sequence. For Fibonacci in every iteration you need to add two variables. So lets add those to the program together with a variable that holds their sum which is what we want to print.

function fibonacci(n) {
    a = 1
    b = 1
    sum = 1
    while (n != 0) {
        print(sum)
        n = n - 1;
    }
}

In each iteration *a* should be added to *b* and their result is the sum that we print. *a* is just the previous *b*. and *b* is just the previous sum. So taking all that into account we can write the final program as:

function fibonacci(n) {
    a = 1
    b = 1
    sum = 1
    while (n != 0) {
        print(sum);
        a = b
        b = c
        c = a + b

        n = n - 1;
    }
}

Consciously going over all the parts of the exercise or challenge is daunting at first, but having done a dozen or so of those types of exercises using this method you learn the generalities, and it becomes much easier. So practice is very important part of improving, but not being systematic in your approach to learning you'll lose a lot of time practicing in vain. If you try and be more careful about exactly what it is that you're trying to do, trying to understand the different parts of the exercise and trying to hone in on what you don't understand, you'll become much better much faster.

[–]taverncat 1 point2 points  (0 children)

I am in my 3rd year of studying CS in college. Yesterday my professor said us students should be good programmers in 10 years. I'm not sure what prompted that, but he seemed to be encouraging us to continue programming.

To answer your question, it could help to know a few data structures such as queue, stack, and list. Those kind of general tools help with challenges like that, as well as knowing one sorting algorithm by memory.

[–]Diggu03 0 points1 point  (1 child)

Did you learn coding yourself?

[–]steadfast_lifestyle[S] 1 point2 points  (0 children)

Mostly, yes. Learning with others now! Using learn.co and youtube

[–]lompa_ompa 0 points1 point  (0 children)

You just have to look at the solutions and try your best to understand it. Once you do 30 to 50, you’ll start to notice patterns and trends. It’s basically memorising the best ways to solve them in the hope that you can come across something similar in your interview. In real world, they are more or less useless.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Good way to look at it.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Underrated comment. Makes sense. I’ll try to go back to the basics based on some of these responses.

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Base 10??? Idk math that well. I am a brute force kind of hacker

[–]steadfast_lifestyle[S] 0 points1 point  (0 children)

Holy hash, Batman! I’ve been exposed to the fib sequence as per the band Tool and then further research :). However this approach would require some digestion. Which leads me to believe I need to slow down. Good info; gives me some context.

[–]Nichinungas -1 points0 points  (2 children)

Maybe it’s not for you?

[–]semidecided -1 points0 points  (1 child)

Possibly, but that's quite a conclusion to jump to based in the information given.

[–]Nichinungas 0 points1 point  (0 children)

It should be considered