FizzBuzz

I came across an interesting article today on weeding out weak programmers. Simply ask them to program FizzBuzz.

Using FizzBuzz to Find Developers who Grok Coding

FizzBuzz is a game children play in the UK where they each sit is a circle and begin to count. The catch is that if the number is a multiple of 3 you have to say ‘Fizz‘, if it’s a multiple of 5 you say ‘Buzz‘, and for multiples of both 3 and 5 you have to say ‘FizzBuzz‘.

Supposedly many computer science majors and other applicants for programming jobs can’t do this simple task.

On occasion you meet a developer who seems like a solid programmer. They know their theory, they know their language. They can have a reasonable conversation about programming. But once it comes down to actually producing code they just don’t seem to be able to do it well.

You would probably think they’re a good developer if you’ld never seen them code. This is why you have to ask people to write code for you if you really want to see how good they are. It doesn’t matter if their CV looks great or they talk a great talk. If they can’t write code well you probably don’t want them on your team.

After a fair bit of trial and error I’ve come to discover that people who struggle to code don’t just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.

FizzBuzz sets out such a simple task that anyone who can program should be able to write up a code that can do this in a couple of minutes. It’s amazing to hear that many of the applicants who apply for a programming job aren’t able to do this.

Perhaps the question is too easy. At first I thought there had to be some sort of catch to it. A trick question. But no, it is that easy. Simply write a program that will count from 1 to 100 replacing multiples of 3 with ‘Fizz‘, multiples of 5 with ‘Buzz‘, and multiples of both with ‘FizzBuzz‘. No tricks. No hidden catches.

So naturally as a programmer myself I immediately had to set out to prove my competence by writing FizzBuzz in PHP. While my design is far from elegant, I assure you that it works, which puts me in that club of programmers who can program.

// SET TWO VARIABLES
$multiplesofthree = 1;
$multiplesoffive = 1;

for ($i=1;$i<=100;$i++) {
if ($multiplesofthree==3 AND $multiplesoffive==5) {
$tehprintout=”FizzBuzz”;
$multiplesofthree=0;
$multiplesoffive=0;

} elseif ($multiplesofthree==3) {
$tehprintout=”Fizz”;
$multiplesofthree=0;

} elseif ($multiplesoffive==5) {
$tehprintout=”Buzz”;
$multiplesoffive=0;

} else {
$tehprintout = $i;
}
$multiplesofthree++;
$multiplesoffive++;

echo “$tehprintout
“;
}

Article: Why can’t programmers.. Program?

Be Sociable, Share!

6 Responses to “FizzBuzz”

  1. vacate cleaning perth geraldton Says:

    vacate cleaning perth geraldton

    Four Points Cardinal | FizzBuzz

  2. penguin jump math playground Says:

    penguin jump math playground

    Four Points Cardinal | FizzBuzz

  3. This Web page Says:

    This Web page

    Four Points Cardinal | FizzBuzz

  4. Paris Longchamp Handbag Says:

    Paris Longchamp Handbag

    Four Points Cardinal | FizzBuzz

  5. line rangers hack apk Says:

    line rangers hack apk

    Four Points Cardinal | FizzBuzz

  6. free pdf downloads Says:

    free pdf downloads

    Four Points Cardinal | FizzBuzz

Leave a Reply

You must be logged in to post a comment.

Be Sociable, Share!

Whitespace Graphic
Quick Buttons Navigation
Tabbed Buttons Navigation
Subscribe to Four Points Cardinal's RSS Feeds Foponet Services F.A.Q. Traffic Exchange Mods Open Source Contact Me About Me FopoNet Blog