Alternate FizzBuzz Questions

Andrew Burns picture Andrew Burns · Sep 22, 2008 · Viewed 46.9k times · Source

Anybody have any good FizzBuzz type questions that are not the FizzBuzz problem?

I am interviewing someone and FB is relatively well known and not that hard to memorize, so my first stop in a search for ideas is my new addiction SO.

Answer

MBCook picture MBCook · Sep 22, 2008

I've seen a small list of relatively simple programming problems used to weed out candidates, just like FizzBuzz. Here are some of the problems I've seen, in order of increasing difficulty:

  1. Reverse a string
  2. Reverse a sentence ("bob likes dogs" -> "dogs likes bob")
  3. Find the minimum value in a list
  4. Find the maximum value in a list
  5. Calculate a remainder (given a numerator and denominator)
  6. Return distinct values from a list including duplicates (i.e. "1 3 5 3 7 3 1 1 5" -> "1 3 5 7")
  7. Return distinct values and their counts (i.e. the list above becomes "1(3) 3(3) 5(2) 7(1)")
  8. Given a string of expressions (only variables, +, and -) and a set of variable/value pairs (i.e. a=1, b=7, c=3, d=14) return the result of the expression ("a + b+c -d" would be -3).

These were for Java, and you could use the standard libraries so some of them can be extremely easy (like 6). But they work like FizzBuzz. If you have a clue about programming you should be able to do most pretty quickly. Even if you don't know the language well you should at least be able to give the idea behind how to do something.

Using this test one of my previous bosses saw everything from people who aced it all pretty quick, to people who could do most pretty quick, to one guy who couldn't answer a single one after a half hour.

I should also note: he let people use his computer while they were given these tasks. They were specifically instructed that they could use Google and the like.