r/programming • • May 09 '15

"Real programmers can do these problems easily"; author posts invalid solution to #4

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

1.3k comments sorted by

View all comments

1

u/egg1st May 09 '15

Falls down if you have a set like [5, 53, 50, 4, 9], because the concatenation of 5 & 4 will give you a higher number than 53. This code gives you 9535054, but the correct answer is 9545350.

5

u/NVShacker May 09 '15

Isn't the correct answer 9553504?

1

u/egg1st May 09 '15

Christ, you're right. I knew it was a bad idea before my first coffee of the day :/

2

u/Doriphor May 09 '15

The correct answer for [5, 53, 50, 4, 9] is actually 9553504...