Thursday, May 31, 2012

In Defense of Programming Puzzles

A few days ago, I read an article on Hacker News, Spare me your puny little coding contest, earthling! that panned programming puzzles as being a waste of time. The author, Adrian Scott, said he would rather be working on real-world projects that people will use. While I'm a huge fan of creating software with a purpose and an audience, I do think programming puzzles have their place. And, I recently used a programming puzzle with great success while recruiting a new junior programmer for LabRetriever.

Hiring junior developers can be tricky. You don't generally need a lot of prior experience for junior developers. And, you may not necessarily care if they have a degree. But, you do want people who have an aptitude for programming and problem-solving. In cases like this, a programming puzzle is a good gate-keeper to help find people who can think logically and use the basics of your language of interest. Once they get past the puzzle, you can bring them in for a personality and technical interview and see how things go from there.

In our small company, HR doesn't screen resumes from applicants. So, every email I receive from a recruiting company, an unqualified person, or somebody who is filling out applications to meet an unemployment quota is a waste of my time. Recently, I posted an ad on Craigslist seeking a junior programmer. Initially, I tried a standard ad. I listed our benefits, the job requirements, etc.. I didn't get many quality responses, but quite a bit of spam from freelancers and recruiters. So, I pulled that ad and replaced it with the following puzzle:



/****************************************************************************/
/* I need a full-time junior web application developer who can work on-site */
/* in the Philadelphia subburbs. Recruiters have been driving me batty by */
/* responding to previous ads even though I politely ask them not to. So, */
/* in an effort to speak directly to my people - I am posing this ad as a */
/* programming problem. I would very much like to hear from entry-level */
/* applicants who are looking for a job where your brains and creative */
/* problem solving skills are admired and respected. */
/****************************************************************************/

function who_are_you(){

// We are a small company that provides specialized, web-based medical software
// to our growing list of clients. We offer flex-time, health insurance, 
// and a casual work environment. You can contact us at:

$cache = array();
$web_site = how_do_i_apply($cache);
$pay_rate = what_are_you_willing_to_pay($cache);


}

function what_are_you_willing_to_pay($cache){
// We are willing to pay up to :
return (typical_college_recursive_function(10,$cache) + 15) * 1000;
// for the right person

}


function what_are_the_job_requirements(){

//1. You should be able to write a basic web application in either php, python, ruby or node js.
//2. We use php and MySQL, but are willing to train the right person.
//3. You need to be a competent writer. We will expect you to document your work clearly.
//4. You need to be authorized to work in the United States. We do not offer any Visa sponsorship
//5. Until you are fully trained, you'll need to work in the office every day. After that, we are open to telecommuting once a week.
//6. To show give us a hint of your skills, we are going to ask you to post the answer to this problem
//7. Along with your resume, at the specified location



}


function how_do_i_apply($cache){

// Calculate the email address that you need to mail your resume and the source code for your solution to.

$key = typical_college_recursive_function(6,$cache);
$key += 25 + (5%6) + 3 - 28;
$code = "ue@fyrrcrk.pbz";
return(give_me_the_email_address($key, $code));



}

function typical_college_recursive_function($n,$cache){

if($n <=2){
return 1;
}else{
if(isset($cache[$n])){
return $cache[$n];
}else{
$cache[$n] = typical_college_recursive_function($n-1,$cache) + typical_college_recursive_function($n-2,$cache);
return($cache[$n]);
}
}



}

function give_me_the_email_address($key, $code){

// Ok. Here is where you come in. This function should decipher the code using the key we provide.
// It's a basic Caesar cipher that shifts the letters of the alphabet based on the value of the key.
// Example: For a key 3 , A = D, C = F, R = U. The decrypted cipher will be the email address that you need.





}


who_are_you();







I didn't include an email address for a response. Within a day or two, the applications started coming in. Every resume was from a viable applicant who could do enough basic PHP to reason out the email address. I received no spam at all. I did receive a few submissions from people who didn't want the job, but thought the puzzle was fun. We got quite a kick out of those around the office. So, programming puzzles may not be for everybody. But, I loved how well one worked for us.