Some years ago, Phil B. invited a promising looking candidate for a developer role to come in for an in-person interview. The candidate in question, Boris, had a very impressive resume showing plenty of C and embedded systems experience; however, upon his arrival, it was clear that his communication and interpersonal skills left a little to be desired.

It wasn’t that Boris was rude or unprofessional, instead it came down to the fact that he was really, REALLY nervous. Throughout the interview, Boris sweated, fidgeted, stumbled with his answers, and eventually asked to be excused for a moment.

When Boris returned, Phil decided to end the interview there - obviously today was not Boris' best day. Willing to give Boris the benefit of the doubt, chalking up the experience to being simply Boris having a fit of nerves, Phil offered an alternative to their "traditional" interview.

Phil gave Boris a take home programming assignment to complete in the language of his choice: write a function to determine whether a given input number was prime. Phil reasoned that assignment like this would determine if Boris had the programming chops making him considered worthy of the position better than being confined to a conference room for an hour.

Boris heartily agreed to email a submission by the end of the week and furthermore, agreed to do it in PHP, which he hadn't used before, but was eager to gain experience in.

Two days later, ahead of his deadline, Boris responded with some zipped up code, a PDF work order indicating an invoice amount of 0.00 and a Word document titled "Proof of time spent"

Here's the extracted code:

if (checkInteger ($Number) == TRUE)
{
print ("The Number " . $Number . "is " . checkPrime ($Number) . "
\n"); } else { print("ERROR: Number-Typ is NOT integer!"); } function checkInteger ($Number) { if ($Number > 1) { return (checkInteger ($Number-1)); } elseif ($Number < 0) { return (checkInteger ((-1)*$Number-1)); } else { if (($Number > 0) AND ($Number < 1)) { return (FALSE) } else { return (TRUE) } } } function checkPrime ($Number) { if ($Number < 2) return ("NOT PRIME."); elseif (($Number == 2) OR ($Number == 3) OR ($Number == 5) OR ($Number == 7)) return ("PRIME."); else { if (($Number%2) == 0) return ("NOT PRIME."); elseif (($Number%3) == 0) return ("NOT PRIME."); elseif (($Number%5) == 0) return ("NOT PRIME."); elseif (($Number%7) == 0) return ("NOT PRIME."); else return ("PRIME."); } }

At this point, Phil was pretty sure that Boris wasn't going to be offered a job but he wanted to follow things to their conclusion.

Hi Boris,

Your work was presented very professionally but your checkPrime function will only work for a very 
limited range of values, can you change it to use a method that will work for all values? 

Regards,
-Phil

Boris replied with an updated solution along with updated document. Here's what his "history" file said:

Ver. 1.0.0.B
New development / first development
Check of an entered number, whether she is a primary number.
CheckPrime()- function work for a very limited range of Integer-values: (-32768,…,32767)

Ver. 1.1.0.B
see SW-Ver. Ver. 1.0.0.B as a base version Expansion / new features / Change:
The number range was extended:
Before: integer-Values (Ver. 1.0.0.B)
Now: double-Values (Ver. 1.0.1.B):
CheckPrime()- function work for a very broad range of Double-Values:
Positive Values 1.79769313486231E308,…4.94065645841247E-324 and 
Negative Values -1.79769313486231E308,…-4.94065645841247E-324

And here was his amended code:

if (checkDouble ($Number) == TRUE)
{
print ("The Number " . $Number . "is " . checkPrime ($Number) . "
\n"); } else { print("ERROR: Number-Typ is wrong!"); } function checkDouble ($Number) { if ($Number > 1) { return checkDouble ($Number-1)); } elseif ($Number < 0) { return checkDouble ((-1)*$Number-1)); } else { if (($Number > 0) AND ($Number < 1)) { return (FALSE) } else { return (TRUE) } } }

Unfortunately for Boris, at this point, his prospects for the position were looking quite grim. Phil had pretty much made up his mind – Boris wasn’t the best candidate for the job. The time had come to gently cut Boris loose.

Hi Boris,

With respect to your test, when I said it worked only for a limited range, I didn't 
mean that you had used the wrong datatype but that your test was incomplete. 
For example, 11*11 = 121 which your test would incorrectly identify as prime. 
To check for primeness, try searching online for "prime number test". There are 
all sorts of very complicated approaches which are not required, just a simple 
test which need not be the most efficient will suffice. 

If you'd still like to complete this then feel free to submit your implementation 
in your own time. We will keep it in mind when considering you for future openings.

Regards,
 -Phil

Boris though had a different interpretation of the quality of his submission:

Hi Phil, 

Thanks for your reply. 

I think that what was delivered represents my approach and style of work very well. You can judge it with that. 

I look forward to hearing from you in the future.

Regards,
Boris

Sufficed to say, Boris did not hear back from Phil's employer again.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!