That sounds solid for a "take home" test, but I wouldn't trust that for an interview (it's too easy to get an answer from some website instead of doing the work), and as others have stated before me it seems far too hard for use in a live code exercise. (I consider myself quite the math geek, but never bothered to memorizing formulas
for pi.) Personally, I've always preferred some variation on the simpler "fizzbuzz"
test, like asking candidates to write the C library strcpy function, or a function to calculate m-of-n boolean logic (given n
logic tests, write a function that returns true when at least m
items are true). These tests actually allow you to check a candidate for several desired attributes at once:
- Ability to read and follow a specification. For instance, for "fizzbuzz" will the candidate remember to print the numbers which fail both modulo tests, and not print the number when one of these test succeeds?
- Familiarity with language of choice/test. The second example, as given, would require one to cold-recall the order of arguments (and return value) to a very common library function; properly coding the boolean logic example requires writing a variadic function.
- Coding practices and problem solving skills. A test with multiple solutions (or at least, seeming to support multiple solutions) allows you to see the candidate's thought process.
As the parent poster stated: you probably can pass this sort of test and only be a 40%-skill programmer, and many 90%-skill programmers would fail at least one of the above tests. However, the how and why candidates 'fail' (did you ask for clarification, or just rush in? Did you mis-read the requirements, or not think the problem through? Does your code contain a fencepost error?) is just as revealing of desired skill set as any 'success'.