Skip to content

Comment on FizzBuzz: the test helps filter out the 99.5% of programming job candidates

Comments

This is by far my favorite interview question to give. In case the candidate may have memorized it, I might make a slight alteration. Like count backwards from 102 to 2 and don't print anything for prime numbers.

prime numbers

Isn't that harder than the actual question?

Is it? Seems to require about the same knowledge as the original FizzBuzz. Even if it didn't, if a candidate couldn't write the logic to determine if a number is prime or not... that's another red flag.

  def is_prime(x):
    if x%3 and x%2:
      return True
    else:
      return False

  print is_prime(4)
  print is_prime(7)
EDIT: Oops, nevermind... you're all right and I'm wrong. I'm not fixing this code so everyone can see exactly how I screwed up.

I can't even tell if you are being sarcastic or not. Either way I certainly wouldn't hire you.

Edit: Perhaps you should keep this in mind next time you declare 99% of programmers incompetent because they made a typo when you asked them to write code down with pencil and paper in a high pressure interview situation.

It's amazing how much doing a few interviews inflates people egos.

Thats unfortunate, you just red flagged yourself! I think its time to never ask your interview candidates that question again.

Rosetta Code has some examples of different methods and different languages. The most naïve way is trial division: http://rosettacode.org/wiki/Primality_by_trial_division

Maybe with respect to debugging someone else's code... The related interview question:

"What's the first (positive) number my function will have wrong?"

I was just reading it again and again to see the thing I was missing :)

0.o

25 ?

Hmm, the only off-the-cuff way I can think of to do that would be an Eratosthene's Sieve -- unless I hardcoded the primes in a fatty switch statement. I think I could remember/figure all the primes in that range in a few minutes.

Am I missing something, or is that basically what you're looking for?

What's the percentage that you filter out in your experience?

I actually don't think I've had anyone completely blow up on it, except once a long time ago in a previous company with someone who turned out couldn't even do helloworld. They usually do it and later all the devs look at the solution if they like it or not. In my company you can't know how everyone votes. It's just a bunch of anonymous "+1"s or "-1" and after the votes are added up if the candidate got a huge negative number it's a no-go. Around zero is handled case-by-case I think and huge positive is extend offer. A neutral person does the vote-counting. I guess the phone screens are doing a pretty good job of dropping anyone who'd bomb it in the office.

So... actually, I don't know if it's filtering anything really. It's just interesting to watch people do it and it at least establishes that the candidate isn't a complete faker.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.