dark mode light mode Search Menu
Search

Fizz-Buzz and Other Odd Questions

photocapy on Flickr

Recently I went through an afternoon job interview, as a writer, talking with five people in four hours, one after the other in a conference room. Aside from the almost comical and grueling quality of the experience (Hit me again! Thank you! Next!), I learned about something one of my friends and long-time business partner calls a Microsoft Question. The last person I spoke with didn’t ask me about technical writing. They asked me how many gas stations there were in the United States.

Oy.

Only after the experience, and my friend’s offhand comment, did I realize they had tossed me a classic type of puzzle question used to sort and qualify job candidates. As you learn computer science and programming then get set to interview, there are at least two types of questions you should know how to answer.

One type of question has to do with writing tiny applications. We can call these Fizz-Buzz questions, as we’ll see. The other type of question is called a Microsoft Question.

Microsoft Questions

This type of interview question is notorious because Microsoft, among other companies, makes a point to ask job candidates impossible to solve questions. These questions are not perverse torture employers ask to amuse themselves. They’re useful ways to see how people think, as well as determine how a candidate responds to the unexpected. For job candidates, they’re also useful ways to find blind spots.

In my case, trying to count US gas stations, my blind spot was to focus on the number of people with jobs in the US, which I happen to know (150 million). While the number of people with jobs is useful to set an upper bound for the number of cars in the US that need gas, it’s useless in determining how many gas stations there might be. Why? Because how much gas a gas station can deliver depends instead on the number of its pumps.

The best way to solve these problems is to define the limits of inputs and outputs for the problem, in this case, the number of pumps, the number of cars (which I got reasonably well), and other factors. However, the key detail is there is no correct answer. That’s odd, certainly, but the point of asking and answering is to show how you think, how you adapt, and your ability to persist.

Here are a few other examples of Microsoft Questions. How many can you answer reasonably well without help?

  • How many gas stations are there in the United States (or Canada, UK, etc.)?
  • What is the reason manhole covers are round?
  • How long would it take to move Mount Fuji in Japan?
  • If the transporter from Star Trek were real, how would that affect transportation?
  • Why does a mirror reverse right and left instead of up and down?

Of these, the manhole cover question is probably most interesting. Turns out these covers are round because a round shape handles the weight of traffic better than a square or alternate shape. One typical answer is round shapes don’t fall into the round tubes they cover. However, all manhole covers regardless of shape won’t fall in because they’re always slightly wider than the hole they cover. It also takes a small tractor and some chain to lift most manhole covers, never mind you or me popping up the cover then dropping it into the tube below.

Plus manhole covers are interesting because they have a Flickr group, Manhole Covers Around the World.

It’s also perhaps amusing that, while puzzle questions have a long history in the computing industry, they’ve been picked up by every kind of employer which, in turn, has led to less than rigorous use. You might find an interviewer insisting manhole covers are round because they don’t fall in.

Fizz-Buzz Questions

Aside from odd puzzle questions in a job interview, programmers might be asked to code a small task on paper. You might call these questions Fizz-Buzz because the small task usually involves recursion and evaluation.

Let’s take one example to consider: write a tiny program to count from 1 to 100. For every number divisible by 3 or 5, write (output) Buzz. For all other numbers, write (output) Fizz. Apparently school kids in the UK play this game in classrooms. Your program would automate this game.

How might you do this without reference to a specific programming language? Can you do it? Where would you begin?

We can figure this out with pseudo code, writing down the logic of the solution without referring to code. To begin, we probably want to accomplish these tasks with our solution:

  • Count from 1 to 100.
  • Start with the number 1.
  • Stop when we reach 100.
  • Evaluate each number to see if it can be divided by 3.
  • Evaluate each number to see if it can be divided by 5.
  • Write or output Fizz.
  • Write or output Buzz.

Can you figure out the next steps to create this tiny program? Here’s how I would write this program, to be processed in this order:

  1. Start with a variable called $count and set it equal to 1.
  2. Create a while statement and set its parameters to while $count is equal to 1 and less than or equal to 100.
  3. Within the while statement, determine if the number is divisible by 3 or 5:
    • If the number is not divisible by three or 5, write or output “Fizz”.
    • If the number is divisible by three, write or output “Buzz” and exit to the end of the while statement (step 4).
    • If the number is not divisible by three but is divisible by five, write or output “Buzz”.
  4. Within the while statement, add 1 to the value of $count.
  5. Return to the top of the while statement and evaluate the updated value for $count. Continue the while statement if $count is less than or equal to 100.

The while statement will limit our results to counting from 1 to 100. And adding 1 to the $count variable as a last step in the while statement keeps our little application going until it reaches 100.

Other similar questions might be to draw on a board the basic table structure for a relational database with authors and books, as well as the SQL query to find all books for a specific author. Or you might be asked to write or code a program to screen scrape data from a website.

Whatever questions you are asked, it’s important to stay calm and focus on the problem and possible solutions. In my experience, job interviews also exist for you (or me) to find out if you want to work for a company.

Learn More

Manhole Covers

http://en.wikipedia.org/wiki/Manhole_cover
http://www.flickr.com/groups/1139924@N21/

How Would You Move Mount Fuji? Microsoft’s Cult of the Puzzle

http://books.google.com/books?id=hojAaIwFn9YC&printsec=frontcover

Using FizzBuzz to Find Developers who Grok Coding

http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/

How to Interview for Programming Jobs

http://www.kegel.com/academy/getting-hired.html
http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html
http://www.codeslate.com/2007/01/you-dont-bury-survivors.html
http://readwrite.com/2008/07/22/top_10_concepts_that_every_software_engineer_should_know