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.

In hiring programmers, a common test is the Fizz Buzz test. What are some neat/interesting variations on fizz buzz which keep with about the same difficulty level?

Basically, if I asked someone to do a fizz buzz test over email or something, I'd want to make sure they can't just google the code.

share|improve this question

closed as not constructive by Mark Trapp Dec 17 '11 at 6:18

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Any of the simpler Project Euler problems ought to fit the bill. Of course, the problem with putting tests here is that they now become public knowledge. –  Robert Harvey Apr 17 '11 at 4:34
3  
@Robert Public knowledge isn't as common as you might think, if someone can actually solve those problems, then there's a big possibility that they can think on their own. –  Mahmoud Hossam Apr 17 '11 at 6:22
    
@Robert well, I'm talking about changes which can be "my choice" such as "insert a multiplier of X" or something. If they can't do a fizzbuzz, they probably can't figure out how to apply a multiplier of X (where X is actually some constant) –  Earlz Apr 17 '11 at 7:32
2  
FizzBuzz is not a common test. The point is that it is embarrassingly easy for any programmer. –  Macneil Apr 17 '11 at 14:05

8 Answers 8

up vote 5 down vote accepted

As others have said, I don't think FizzBuzz is appropriate over email, but might be appropriate at some other place (say, at a job fair where you need a way to rapidly discard resumes that are a waste of both the interviewer's and applicant's time to pursue). It's really only appropriate for sorting candidates into two buckets: programmers and not.

So with that out of the way, assuming you're targeting an appropriate environment, here are a few other quick ones:

  1. Write a function that takes in a two-dimensional array of ints (or a List<? extends List<? extends Number>> or equivalent) and finds the smallest number in each row, and returns the sum of those per-row smallest values. (Or returns the minimum value overall, or the row index which contains the largest minimum, etc.)

  2. Print out a portion of Pascal's triangle: specifically, ask them to write a function that takes an integer (a) and prints out the first a rows of Pascal's Triangle.

  3. Write a function that prints out a breakdown of an integer into a sum of numbers that have just one non-zero digit. For example, given 43018 it should print 40000 + 3000 + 10 + 8.

  4. Related to that, write a function that will accept an integer number of cents and print out a breakdown into pennies, nickels, dimes, quarters, (whatever else you want - half dollars, dollar coins), using the fewest number of coins.

  5. Anything from the "Coding" section of this: http://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions

share|improve this answer

FizzBuzz is not meant as a test of ability, it's meant as a way to weed out the incompetent.

It should take all of 5 minutes. In person (or via a shared document). And if the candidate can't solve it as fast as he or she can write, then there should be some red flags going up.

Giving FizzBuzz or any similar problem as an email problem does two things: (1) it doesn't weed out the incompetent, and (2) it throws up red flags to any competent candidate that your company isn't very good at interviewing.

share|improve this answer
    
Doing these in-person is a big waste of time. –  Job Apr 17 '11 at 17:13
7  
Fun fact: I've given the FizzBuz test to every programmer I've interviewed. I don't think I've ever seen one who could solve it in less than 10 minutes. –  nikie Apr 17 '11 at 20:01
2  
@Job - agreed, if you have a decent screen in place. But I've worked for companies that don't do a front-end screen, so I'm willing to spend 5 minutes at the start of an interview. Much less a waste of time -- my time, at least -- than sitting through a half-hour or hour-long interview with someone that I won't want to hire. For the incompetent candidate, on the other hand, it may well be a waste of time. I don't particularly care about that. –  Anon Apr 17 '11 at 20:50
    
@Nikie - then sorry, but I think you're doing it wrong. If someone asks lots of questions, maybe I'd let them slide. But if they stumble along and can't figure out that it's a loop and an if, it's time to politely say "the interview is done." –  Anon Apr 17 '11 at 20:52

If you change the words "fizz" and "buzz", it quickly becomes ungoogleable. If they've studied common interview questions they might still recognize it, but at least it indicates a level of preparedness that puts them above average.

share|improve this answer

How about asking them to solve fizzbuzz with recursion? or with no integer division.

share|improve this answer

One example of a programming 'test' I was given recently was I had to write a method which would multiply 2 integers, without using the '*' character. It is very simple, but the question was not about gauging my competency, it was about being able to review the code I wrote, point out any possible issues with it, areas in which improvements could be made.

share|improve this answer

When it comes down to it, FizzBuzz leverages the most basic of programming concepts, including (as Bob Martin tends to put it) Sequence, Selection and Iteration. What you can do is provide a new question, similar to FizzBuzz, but leverage more advanced language concepts for pattern matching. For example, instead of using numbers, perhaps instead you are dealing with a collection of entities, which are polymorphically related. This would allow you to check the candidates knowledge of polymorphism, interfaces, inheritance, etc. For your selection, instead of modulus like traditional FizzBuzz, you could be looking for type matching on the elements.

I'm not sure if this is what you meant by requesting ideas with the same difficulty, but I tried to envision how I might ask this question in an interview.

share|improve this answer

If they claim to know C++ (and don't) you can always tell them to write FizzBuzz with templates.

While potentially fun, I wouldn't consider this in very good taste. If they claim to be an expert in C++ and aren't, I consider this fair game.

share|improve this answer
2  
What, you mean write it as a meta-program that computed FizzBuzz at compile time and then outputted the result as a compiler error? –  user23157 Apr 17 '11 at 10:22
    
Before doing this, though, I'd ask them to rate their knowledge of "advanced C++" on a 1-10 scale. If they place it at or above 7, only then would I torture them with this question. Otherwise the candidate is already being honest enough about how well they know C++, making such a question redundant. –  romkyns Apr 17 '11 at 13:32

How about making it specific to your stack to show that the person has at least fiz-buzz type ability with your framework/platform. If it was a Winforms developer position for example:

You have a Window called MyWindow that has various controls on it. Write a method that will make all of the textbox backgrounds red. Make all of the label backgrounds blue. If a textbox or a label currently says "fizzbuzz", then set its background to purple.

This should be trivially easy for any Winforms developer to do with pen and paper. It demonstrates a bit of knowledge of Collections, .Net Control heirarchies, iteration, conditionals, and inheritence.

share|improve this answer

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