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

809

u/holypig May 08 '15

Well this asshole should stop calling himself a software engineer, since his solution for #4 is WRONG!

https://blog.svpino.com/2015/05/08/solution-to-problem-4

Try running with [52,5,3]

80

u/goomyman May 08 '15

not to mention number 3 goes beyond big int in size... so your going to have to write your own addition and output methods.

soo ya.. great questions /not. Just goes to show what you think is an easy question can be quite difficult on the spot, on a whiteboard, with pressure.

0

u/[deleted] May 09 '15

[deleted]

2

u/whooshayay May 09 '15 edited May 09 '15

PHP has no tail call optimization. So, why would you do fibonnaci recursively? An iterative solution, i.e. a for loop, would be much more efficient in PHP.

def fib (terms):
    t0, t1 = 0, 1
    for i in range (terms):
        t0, t1 = t1, t0 + t1
    return t0

Yes I know this is Python. I'd probably bugger up the syntax if i did it in PHP but you should be able to infer the iterative loop from that code.

→ More replies (4)