In 2005 I posted this on my blog, quoted here for posterity:
A friend gave me a photocopy of a worksheet from a programmer job interview, the contents of which I'm transcribing here. Probably the worst interviewee experience I've seen. I've tried to be reasonably fair; arguably I should could be generous and use * in place of ·, since this was handwritten, but given all the absolute conceptual failures and mental disconnects, I'm leaving it as is.
So the interview "challenge" was to write a factorial function. Now, I don't know exactly how well or poorly the problem was described by the interviewer, but given the first line, probably copied from a whiteboard, I'm assuming it was pretty straightforward. Here's what the sheet had on it...most of the strikes are circular scribble-outs:
5! = 1·2·3·4·5
public string access(string 5! a)
{
string
string b = a.substring(0,1);
string
Int int c = b String.getValue(b);
if(c < 2){
System.System.err.println("1");
} else if (c < 3){
System.err.println("1·2");
} else if (c < 4){
System.err.println("1·2·3");
}
For someone aspiring to a Java development position, and who must've sounded at least possibly decent on the phonescreen...supposedly the person has multiple masters degrees in science-y and computer-science-y fields, both from good local Universities.
For the non-techies on my blog I summarized the issues like this:
1. Returning a string? Already something seems a bit amiss.
2. Why name a function like this "access"?
3. Passing "5!" as a a variable name, even though struck out, is a telling mixup of variable name and content.
4. More string oddness. These two lines seem to indicate he's just trying to parse the first character of the String passed in to an int, ignoring the rest.
5. To the right of "c -", there's NOTHING about Integers...I'm willing to give him a pass in terms of specific function name (Integer.valueOf(String) would have "worked" as a replacement for String.getValue(String)) but he's not even in the ballpark.
6. The use of "if"s here, 3 conditional cases, is just an astounding example of misthink. Logically, only Strings starting with 0-3 will produce any output, and even then if it's a "one digit string" of the values 1-3 could this logic conceivably "work".
7. Finally, the use of "System.err" rather than "System.out" is just... well, wrong. Or maybe so right, a subtle bit of self-commenting on the error-ridden code...
An even half-way decent programmer when given this problem would likely think for a moment and then say "do you care if it's solved recursively or iteratively"? (With the latter being the better bet, performance wise, but that's a small issue). Also, this is kind of an "academic" problem, and the guy seemed to have a strong academic background...besides talking a *great* game about all the latest technologies, and getting some complex stuff about J2EE right. It's just really odd.