Can You Solve the FizzBuzz Programming Interview Test?

fizz_buzzI was recently on an interview with a candidate who mentioned that his programming team (he is a manager) will often pass around interesting programming quizzes or challenges they learn about as a fun way to keep the mental floss going, (or secretly prepare for job interviews).

One such test is called FizzBuzz.  This is a pretty simple test that comes from a math game that many children (apparently common in the UK) play.

The question, altered for programming, is posed as:

“Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.” #permalink

Near as I can tell, the relative popularity of this coding test comes from a post by Imran Ghory called “Using FizzBuzz to Find Developers Who Grok Coding” along with a popular commentary on this by Jeff Atwood called “Why Can’t Programmers.. Program?” along with observations from several others about this that programmers are having a pretty hard time, well, programming.

I’m starting to get a little worried. I’m more than willing to cut freshly minted software developers slack at the beginning of their career. Everybody has to start somewhere. But I am disturbed and appalled that any so-called programmer would apply for a job without being able to write the simplest of programs. That’s a slap in the face to anyone who writes software for a living.

The vast divide between those who can program and those who cannot program is well known. I assumed anyone applying for a job as a programmer had already crossed this chasm. Apparently this is not a reasonable assumption to make. Apparently, FizzBuzz style screening is required to keep interviewers from wasting their time interviewing programmers who can’t program.#

  • So, have you ever done the FizzBuzz test?
  • How would you implement a solution to this test?
  • What are other coding challenges like this that you have seen? …Designed to be “blindingly, intentionally easy”… you either know it or you don’t type questions?
  • Bonus question: What very LAME or IMPRACTICAL coding tests have you witnessed or (sadly) had thrust upon ye?

For me, I am not pretending I am a programmer, but without looking up solutions, I was able to write a functional program for this in JavaScript in 19 lines (including 2 lines for <script> tags) that outputs to html and only tests each iteration for 3 or 5 once each (reducing redundant math). I have uploaded my code already and scheduled a post to go-live in a week with my solution for FizzBuzz (on Halloween, coincidentally). Lets see what you can do before then??

Interestingly, in a recent follow up on this from about a year ago, Joey Devilla calls FizzBuzz his “Sorting Hat” and notes that FizzBuzz still works, and results in only a 40% success rate for the programmers he quizzes with it.

And this funny picture:

Graphing a 33% success rate...

Graphing a 33% success rate…

 

Post your code result below (or link to it in your comment)?

The following two tabs change content below.

Robert Merrill

Senior Technical Recruiter
I am a Husband, Dad, Recruitinator, Geek. Mormon. Smart-Alec. . Professionally, I am the Senior Manager of Talent Acquisition at Ancestry.com", the world's largest online family history resource. Check out our jobs! Since 2001, I have helped connect companies and talented professionals with a particular style of recruiting, interviewing, onboarding and retention that helps companies change their recruiting processes and capabilities forever. I believe that even small companies can do fantastic recruiting with the right tools and mindset.

Latest posts by Robert Merrill (see all)

2 thoughts on “Can You Solve the FizzBuzz Programming Interview Test?

  1. I’ll see your 19 lines of JavaScript code and drop it down to 16. That still includes the opening and closing script tags and only doing the math once per number. It even includes a blank line in the code for better readability. :-)

    Brings the total to 13 lines of actual executing JavaScript code.

Leave a Reply