# beanz Magazine

## Fizz-Buzz and Other Odd Questions

photocapy on Flickr

There are at least two types of questions coders might face in job interviews, fizz-buzz and puzzle questions. Both can be learned ahead of time.

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.
• 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.

#### Using FizzBuzz to Find Developers who Grok Coding

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

### Summer 2014 Code and Technology Camps

It may be the middle of winter in the Northern Hemisphere but now might be a great time to start thinking about technology summer camps if you're a kid or have kids.

### An Interview with Susan Kare

You’ve looked at and used Susan Kare’s work, or work inspired by hers, every time you use a computer. The garbage can icon and other taken for granted icons can be traced back to Kare’s icons on the first Macintosh computers.

### User Experience Designers

User experience design touches on all the ways people interact with software or hardware. This includes how people use technology, the hardware design, and documentation.

### Database Design

How you store and retrieve data in a relational or NoSQL database depends on how well you design the database structure.

### How to Create Color Palettes

Here are several ways to create a color palette that looks professional for web sites and interfaces. It's not as easy as you might think.

### Fizz-Buzz and Other Odd Questions

There are at least two types of questions coders might face in job interviews, fizz-buzz and puzzle questions. Both can be learned ahead of time.

### Interface Design Basics

Interfaces are the primary way people work with computers and websites. Here are concepts used to design human interactions with computers.

### A Short History of Lorem Ipsum

No discussion of design is complete without the history of lorem ipsum. It's more than placeholder text you stuff into a visual design.

### docstrings

Docstrings are special comments embedded in software code that survive compiling the code, for example, help text.

### Database Normalization

Relational databases need to have their data organized a certain way.

### What is Information Architecture?

When you think of architecture, you think buildings not information. However, information also needs careful design and structure in computing.

### JavaScript

JavaScript is a programming language and an historical artifact from the early internet conflicts between Netscape, Microsoft, and Sun for open standards.

### News Wire Stories for February 2014

Interesting stories about computer science, software programming, and technology for the months of December 2013 and January 2014. More stories can be found at the News Wire link at the top of of this site.

### How to Build a (Simple) Website

Here is the simplest possible way to learn how to build a website, as well as how web pages and websites work.