News for hackers. Stuff that matters.
Re:Life, the Universe and Technical Interviews by Retric on Friday August 01, 2014 @11:56PM (#8123946)
I have seen plenty of useful code far worse than sorting such an array. IMO, someone missing the 'obvious' choice in an interview question is completly reasonable.

Thinking back how many people verified that the array was non empty and it had more than one element? I call it the toy problem mindset, when coding you consider things deeply but in meetings your looking for roadblocks not optimal solutions.

PS: From a preformace standpoint sorting your array is relativly better than ant of the posted solutions. Even though the article links to a much faster method. Aka there x log x solutions when a log x solution exists.

Re:Life, the Universe and Technical Interviews by tempestn on Saturday August 02, 2014 @03:48AM (#8124357)
Most people didn't think to check that the array had at least two elements, but more did that than managed to correctly loop through it.

I'm not sure what your PS is referring to. Which posted solutions, and what article?

Re:Life, the Universe and Technical Interviews by Retric on Saturday August 02, 2014 @09:53AM (#8124899)
link at the top...

"life the universe and technical interviews" http://diegobasch.com/life-the-universe-and-technical-interv....

Every solution has a loop 1 to 1000000 which is N but then they check every digit which is a log N making them N log N solutions. But there are Log N solutions that avoid checking every possibility.

Ex:

s dup if 10 /mod recurse + then ; : f 0 1000000 0 do i s 42 = if 1 + then loop ;