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.

Spent some time searching, couldn't find exactly what I'm after.

We like giving hands-on programming exercises as part of the interview process. The interviewee gets a laptop, with the editor and compiler of his choice. He or she then get a programming exercise and has about an hour to code it. Depending on the nature of the question, internet access is either allowed or forbidden.

I'm looking for good general questions for a junior developer. I don't care what language they choose to program in. C++ is as good as Python or Scheme, as long as (s)he can program in it (this rules out "can you write a correct copy-constructor" style questions). I just want to see how they code, if their code is self-documenting, if they write tests, check edge-cases, etc.

What kind of questions would you ask?


edit: The questions should be simple. I'd probably go with a question I can solve well in no more than 20 minutes. However, this is not the first stage in the interview process, and I can assume the person in front of me knows how to program.

Example question:

c is a complex number.
Z(n+1) = Z(n)^2 + c
Z0 = 0
c belongs to the set M iff |Z(n)| < 2 for all natural n

For all c between (-2, -i) to (2, i), print:
'X' if c is in M
'.' otherwise

This looks like a scary mathematical problem, but it's actually very easy, and can be coded in under 10 minutes. Once you get the correct answer, it is visually obvious that you have the correct solution

edit: If the candidate doesn't remember his complex numbers, I show them everything they need about it. I want to see if they can look at a scary problem, and know which questions to ask. For example, you have to use SOME_BIG_NUMBER in the partial solution below

def isInSet( c ):
    z_n = complex(0, 0)
    for i in range(1, SOME_BIG_NUMBER):
        z_n = z_n**2 + c
        if abs(z_n) > 2:
            return False

    return True
share
20  
If I was given that question I'd have to say: "Is a knowledge of complex numbers a requirement for this position? because In 14 years as a professional programmer I've never needed to utilize them. Would you please give me a quick overview?" Depending on your response, I'd then immediately know if it was worth continuing the interview. –  Ash Jun 14 '10 at 12:23
2  
@djhworld - I want to see if they can take a not-so-well defined question (what is "for all natural n" in a computer anyways?) and translate it to a programming question. There are quite a few questions I expect the candidate to raise here, which would be a good sign. But going from a domain-specific question to a programming question is part of the deal here. –  Gilad Naor Jun 14 '10 at 12:40
2  
Stefan: "expresso"? –  Ken Jun 14 '10 at 17:19
3  
"For all c between (-2, i) to (2, i)"... this is an uncountably infinite domain. What, exactly, are you asking for? Are you sure you didn't mean "c is a Gaussian integer"? –  Derrick Turk Jun 14 '10 at 17:26
2  
Scary? Looks like FizzBuzz... :-/ –  Andrea Dec 22 '11 at 9:13
show 14 more comments

migration rejected from stackoverflow.com Mar 16 at 19:53

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as too broad by MichaelT, gnat, Thomas Owens Mar 16 at 19:53

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Why not give them some problem they'd actually face while on the job? One of the few times I was given a test like this, the problem was to describe what a piece of code did and find the bug in it. The code was something they had pulled from their actual codebase and the bug was non-trivial but pretty easy to spot if you knew what to look for (in one case a character string might not be null-terminated, IIRC). Once that part was over, it led naturally into a discussion of what they were doing and the kind of problems they were working on.

share
add comment

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