3 ms·
Interesting (to me) observation: I found I spent significantly more time on the scaffolding for this problem to prove my answer correct, than on the answer itse
by logic 16y ago
Interesting (to me) observation: I found I spent significantly more time on the scaffolding for this problem to prove my answer correct, than on the answer itself. (I'm one of those folks addicted to "FizzBuzz"-esque toy problems.)
I probably spent five minutes at most working out a reasonable way to do this in-place with a single pass, but spent 20-30 minutes reassuring myself that I had it right for all cases.
These kinds of problems are always interesting to me: they have simple and obvious (after some thinking) answers, but probably aren't something you've touched in a significant amount of time, because nobody reinvents the wheel like this day-to-day. They're very satisfying in a "back to basics" kind of way.