Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am in charge of selecting a new software development intern for a company that I work with. I wanted to throw a little 'quiz' at the applicants before moving forth with interviews so as to weed out the group a little bit to find some people that can demonstrate some skill.

I put together the following quiz to send to applicants, it focuses only on PHP, but that is because that is what about 95% of the work will be done in.

I'm hoping to get some feedback on
A. if it's a good idea to send this to applicants?
B. if it can be improved upon?

# 1. FizzBuzz
# Write a small application that does the following:
#   Counts from 1 to 100
#   For multiples of 3 output "Fizz"
#   For multiples of 5 output "Buzz"
#   For multiples of 3 and 5 output "FizzBuzz"
#   For numbers that are not multiples of 3 nor 5 output the number.

<?php



?>

# 2. Arrays
# Create a multi-dimensional array that contains
# keys for 'id', 'lot', 'car_model', 'color', 'price'.
# Insert three sets of data into the array.

<?php



?>

# 3. Comparisons
# Without executing the code, tell if the expressions
# below will return true or false.

<?php

    if ((strpos("a","abcdefg")) == TRUE) echo "True";
    else echo "False";
    //True or False?

    if ((012 / 4) == 3) echo "True";
    else echo "False";
    //True or False?

    if (strcasecmp("abc","ABC") == 0) echo "True";
    else echo "False";
    //True or False?

?>

# 4. Bug Checking
# The code below is flawed. Fix it so that the code
# runs properly without producing any Errors, Warnings
# or Notices, and returns the proper value.

<?php

    //Determine how many parts are needed to create a 3D pyramid.
    function find_3d_pyramid($rows) {
        //Loop through each row.
        for ($i = 0; $i < $rows; $i++) {
            $lastRow++;
            //Append the latest row to the running total.
            $total = $total + (pow($lastRow,3));
        }
        //Return the total.
        return $total;
    }

    $i = 3;
    echo "A pyramid consisting of $i rows will have a total of ".find_3d_pyramid($i)." pieces.";

?>

# 5. Quick Examples
# Create a small example to complete the task
# for each of the following problems.
#   Create an md5 hash of "Hello World";
#   Replace all occurances of "_" with "-" in the string "Welcome_to_the_universe."
#   Get the current date and time, in the following format, YYYY/MM/DD HH:MM:SS AM/PM
#   Find the sum, average, and median of the following set of numbers. 1, 3, 5, 6, 7, 9, 10.
#   Randomly roll a six-sided die 5 times. Store the 5 rolls into an array.

<?php



?>
share|improve this question
6  
This has been cross-posted at: workplace.stackexchange.com/questions/6047/… Please do not cross-post. –  FrustratedWithFormsDesigner Nov 6 '12 at 19:29
3  
Related: How can I test PHP skills in a interview? (Note that StasM, one of the answerers there, is a core PHP developer) –  Yannis Rizos Nov 6 '12 at 19:30
1  
Seems logical except I don't know what you mean by a multi-dimensional array with those keys? Perhaps it's my ignorance of php, in php are all arrays associative? and are those listed items the keys or the values? What are the 2 dimensions (I assume it wants 2?) supposed to be? First dimension is numerical index second dimension is string-associative keys you listed? Perhaps a little more explanation of that problem. Also, if string position is a function in php which returns true or false I am totally conjuring the php double-clawed hammer image in my head heh –  Jimmy Hoffa Nov 6 '12 at 19:33
1  
@JimmyHoffa Yes, in PHP all arrays are associative. Also strpos() returns the position, however == in PHP checks for equality with type juggling, zero == false, so the first comparison is actually a trick question (or a mistake Jeremy?). You'd have to use === to check whether the values are equal and of the same type. –  Yannis Rizos Nov 6 '12 at 19:44
2  
Good idea, but probably not in the way you thought. The first thing to do is drop considering any who answer your questions. The ones who might be worth something are those who run away when you mention PHP. –  Jerry Coffin Nov 6 '12 at 23:18
show 1 more comment

3 Answers

Your code 'quiz' seems like it was written by an amateur to PHP. I can understand the need to vet potential developers before continuing the interview, but why do so with a poor method?

Does your application PHP code resemble the interview quiz you've displayed or are requiring? If yes, the interviewee would (should) be running away from this job. If no, then why are you using it as a metric for hiring?

If it is possible, I would suggest using a current days bug in the production code for testing your potential employee. Okay, you say, but the bugs are either too complex or won't test the persons skill enough in the interview. Wrong, I say. Let the potential developer view (and potentially fix even a small bug/optimize) a portion of (non confidential) code that your company is working on. This will give you a much better idea about their understanding of your company's methodologies and what they'll be expecting to code.

Reference from Jeff Atwood's blog:

If you want to determine beyond the shadow of a doubt if someone's going to be a great hire, give them an audition project. I'm not talking about a generic, abstract programming problem, I'm talking about a real world, honest-to-God unit of work that you need done right now today on your actual product. Something you would give to a current employee, if they weren't all busy, y'know, doing other stuff.

Failing the above, at the very least I'd suggest having the potentials bring in some code samples (if you don't already). Let them show you their previous work, show you how they think in realtime when implementing a function, algorithm, or class. Yes, some may ask for access to documentation or the almighty Google; but at least they won't be at home with infinite time and access to solve your 'quiz'. Knowing where to find an answer and HOW to formulate a smart question to find that answer is a Good Thing™(Unless of course you're asking them to write a 'Hello World')

I must reference Joel Spolsky even though this blog article is a bit old, it is relevant:

Any skill set that people can bring to the job will be technologically obsolete in a couple of years, anyway, so it’s better to hire people that are going to be able to learn any new technology rather than people who happen to know how to make JDBC talk to a MySQL database right this minute.

This to me, translate to Quit trying to hire someone to get <immediate problem 42> done right now and hire someone who can quickly and effectively learn about <immediate problem 42 and its solution> in the near future. Hire someone who is trainable!

Tl:dr answer: If you want to hire a great programmer, use a great interviewing process. If your quiz is to be the 'front line method' prior to a formal interview, there are more programmer centric testing companies. You may want to try out Codility or InterviewZen (also referenced from Jeff Atwood's blog) instead.

Good luck.

share|improve this answer
    
+1 I agree with this completely. When I went for an interview at my current job I had to make two bugfixes to production code - not only did it show them I could do the job but it also gave me a good idea of exactly the type of code I'd be working with. –  Mansfield Nov 7 '12 at 13:37
add comment

Question #3 isn't particularly useful. You have to assume people will "cheat" at home. Asking them to deduce output with running it is pushing that trust boundary.

And I agree with Kevin on the filtering out the hopeless. That's better than nothing. But back to the cheating - you don't know the person you are interviewing was the one who took the quiz. So don't assume tech knowledge when the candidate shows up.

share|improve this answer
add comment

It's ok for filtering out the completely hopeless. It shouldn't be a problem for any programmer, whether or not they have any experience in PHP. I haven't written a line of PHP but working at home with the internet I'm sure I could complete this in an hour or two.

P.S. I'm not keen on the name 'find_3d_pyramid'. Typically 'find' implies some sort of iterative search, not a simple calculation. We don't 'find' the square of a number. A better name would be 'sum_of_cubes' or some other noun phrase. Also, if the function is calculating a sum of cubes, the correct code is simply (n * n * (n + 1) * (n + 1)) / 4

share|improve this answer
4  
+1 for "ok for filtering out the completely hopeless"... and also good for filtering out people who have better offers with less obnoxious quizzes. –  FrustratedWithFormsDesigner Nov 6 '12 at 19:36
    
The first applicant so far has a month of experience on his resume in the IT field, which was as a quality assurance person. I don't expect for this to ween out the superstars from the good programmers. Just to ween out the 'no clue' from the capable. –  Jeremy1026 Nov 6 '12 at 19:38
1  
@FrustratedWithFormsDesigner given an offer from a place that tested me for technical skills vs. one that didn't I'd choose the former every time. I've worked at places that weren't choosy about who they brought in and there's a lot less knowledge capital to learn from in those environments in my experience. –  Jimmy Hoffa Nov 6 '12 at 19:42
    
@JimmyHoffa agreed on wanting to work with places that have standards for who they hire! –  Jeanne Boyarsky Nov 6 '12 at 20:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.