http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/
I found this quite interesting. Basically, given the following description:
Only about ten percent of the professional programmers given the task of translating the above code into a language of the choice did so correctly, given all the time they needed.
The linked blog post gave the following rules:
I thought I would ask the same here at Ars, to see how we stack up. Follow the above rules, and post your results!
I found this quite interesting. Basically, given the following description:
Binary search solves the problem [of searching within a pre-sorted array] by keeping track of a range within the array in which T [i.e. the sought value] must be if it is anywhere in the array. Initially, the range is the entire array. The range is shrunk by comparing its middle element to T and discarding half the range. The process continues until T is discovered in the array, or until the range in which it must lie is known to be empty. In an N-element table, the search uses roughly log(2) N comparisons.
Only about ten percent of the professional programmers given the task of translating the above code into a language of the choice did so correctly, given all the time they needed.
The linked blog post gave the following rules:
Here are the rules:
Use whatever programming language you like.
No cutting, pasting or otherwise copying code. Don’t even look at other binary search code until you’re done.
I need hardly say, no calling bsearch(), or otherwise cheating
Take as long as you like — you might finish, and feel confident in your code, after five minutes; or you’re welcome to take eight hours if you want (if you have the time to spare).
You’re allowed to use your compiler to shake out mechanical bugs such as syntax errors or failure to initialise variables, but …
NO TESTING until after you’ve decided your program is correct.
Finally, the most important one: if you decide to begin this exercise, then you must report — either to say that you succeeded, failed or abandoned the attempt. Otherwise the figures will be skewed towards success.
I thought I would ask the same here at Ars, to see how we stack up. Follow the above rules, and post your results!

