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/Doriphor May 09 '15

Padding is a good idea but you need to pad numbers with their last digit not 0. (Wait, does that work?)

1

u/luciusplc May 09 '15 edited May 14 '15

It doesn't for [4545, 45451, 45, 45456] (4(5)* will be before 45456 - obviously wrong). You need to pad it in circular way.
Here is my solution that works similar but instead of padding, it reads smaller circularly: Solution.

EDIT: Discussion that expalins it better

2

u/Doriphor May 09 '15

You're right. Damn. Now I have to understand your code. Thanks!