r/programming • • May 08 '15

Five programming problems every Software Engineer should be able to solve in less than 1 hour

https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour
2.5k Upvotes

2.1k comments sorted by

View all comments

584

u/__Cyber_Dildonics__ May 08 '15

The fifth question doesn't seem nearly as easy as the rest (the fourth question is not that hard guys).

186

u/orclev May 08 '15

That fifth one honestly has me a bit stumped... I can see how to brute force it, but there's got to be a simple solution. All the others are pretty simple and shouldn't require too much thought even if you've never seen them before.

180

u/youre_a_firework May 08 '15

#5 is probably NP hard since it's kinda similar to the subset-sum problem. So there's probably no way to do it that's both simple and efficient.

161

u/Oberheimz May 08 '15

I actually went ahead and tried solving them, it took me 42 minutes to write a solution for the first 4 problems and I was unable to finish the fifth within one hour.. Am I a bad software engineer?

378

u/mariox19 May 08 '15

If it's on the Internet, it must be true. Every good software engineer knows that.

→ More replies (2)

100

u/gizzardgullet May 08 '15

Now you write your own quiz based on logic tricks that you are comfortable with and challenge the author complete your quiz in an hour.

→ More replies (6)

29

u/akshay2000 May 08 '15

Nah, you're just fine. It's the implementation that took time. The hour criteria is rough since one might just go on and on.

→ More replies (2)

16

u/ours May 08 '15 edited May 08 '15

Are you able to solve the problems that present themselves at work? If so, then no you are not a bad engineer.

Edit: if(solvesProblems) not if(!solvesProblems)

4

u/Oberheimz May 08 '15

Well, of course, wouldn't have a job otherwise ;)

11

u/ours May 08 '15

of course

I've worked with enough people to learn that sadly some that can't/don't want to code can coast surprisingly long in a sufficiently shitty environment.

Best one was a new hire who was supposed to be my senior ask me the most basic question about how to make a "if" condition. I chalked it of to one of those "doh I forgot something super basic" that can happen to any of us.

They realised the dude didn't know how to code at all only because I left for a month-long sabbatical and noticed nothing was done during my absence.

→ More replies (2)

11

u/Dakarius May 08 '15

You're looking at it the wrong way. It takes 5 hours to do 5 problems. You got the first 4 knocked out in 42 minutes leaving you 4 hours and 18 minutes for the last. You've still got 3 hours and 18 minutes left!

6

u/s-mores May 08 '15

Did you just write code to solve them, or put the code in action and tested it?

The only one I tested out was #4 and some syntax parts of #5. Since this is an interview question, it should mostly be measuring the approach and that you know how to do something or at least have some idea how to approach the problem instead of the actual result, which is pretty uninteresting, and in the case of #1-#4, trivial.

I mean, I'm not going to use 5-10 minutes per task in figuring out where I'm missing a semicolon, or where I've misremembered argument order and the code would fail because of that, that's what the compiler is for.

4

u/secondchimp May 08 '15

It's ok, the author's first solution to the 4th problem was incorrect.

→ More replies (26)