Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

fizzbuzz

Name: Anonymous 2009-12-04 0:39

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.

So I set out to develop questions that can identify this kind of developer and came up with a class of questions I call “FizzBuzz Questions” named after a game children often play (or are made to play) in schools in the UK.

In this game a group of children sit around in a group and say each number in sequence, except if the number is a multiple of three (in which case they say “Fizz”) or five (when they say “Buzz”). If a number is a multiple of both three and five they have to say “Fizz-Buzz”.

An example of a Fizz-Buzz question is the following:

[quote]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”.[/quote]

Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes.

Want to know something scary ? – the majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.

I’m not saying these people can’t write good code, but to do so they’ll take a lot longer to ship it. And in a business environment that’s exactly what you don’t want.

This sort of question won’t identify great programmers, but it will identify the weak ones. And that’s definitely a step in the right direction.

Name: Lisp 2009-12-08 21:34

>>78
>>80
YHBT

>>79
But >>73 is the only decent solution in this thread.

Name: Anonymous 2009-12-08 21:35

IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZBUZZ.
PROCEDURE DIVISION.

COBOL COULD YOU PLEASE PRINT THE NUMBERS FROM ONE TO ONE HUNDRED
ON THE SCREEN IN A LIST.

FOR NUMBERS WHICH DIVIDE BY THREE GIVING AN INTEGER RESULT PRINT "FIZZ" TO THE SCREEN.

FOR NUMBERS WHICH DIVIDE BY FIVE GIVING AN INTEGER RESULT PRINT "BUZZ" TO THE SCREEN.

FOR NUMBERS WHICH DIVIDE BY BOTH THREE AND FIVE TO GIVE AN INTEGER RESULT PRINT "FIZZBUZZ" TO THE SCREEN.

THANK YOU COBOL MAYBE LATER WE CAN HAVE TEA TOGETHER.
WOULD THAT NOT BE NICE.

STOP RUN.

Name: Anonymous 2009-12-08 22:06

>>81
The majority of PHP code I've seen contains something a lot like >>75. Even if it is a troll, someone somewhere has written PHP like that and meant it, and everyone in this thread has seen it (even if only by accident, say when apache fails to load mod_php: the result is php of this caliber.)

Name: Anonymous 2009-12-08 22:13

FEEN

Name: Anonymous 2009-12-08 22:18

>>82
Oh fuck I lol'd.

Name: Anonymous 2009-12-08 22:29

>>82
Wow, that's pretty readable. Beats FIOC. I'll be trying out COBOL!

Name: Anonymous 2009-12-08 22:30

>>82
I can't do that, Dave.

Name: Anonymous 2009-12-08 23:27

>>86
That's not valid COBOL.

IHBT

Name: Anonymous 2009-12-08 23:31

>>88
PROCEDURE DIVISION.

MAIN-LOGIC SECTION.
BEGIN.

COBOL PLEASE LET >>88 KNOW HE IS EQUAL TO MORON.


THANKS.
STOP RUN.

Name: Anonymous 2009-12-09 1:16

Oh shit , sorry guys. >>75 here, >>76 is right, I made a mistake , it should be

  while ($i < $n) {
    $i += $q;
  }
  if ($i == $n) return "1";


The FOR loop is wrong. I need to use while here. SOrry XD

Name: Anonymous 2009-12-09 2:37

>>90
Please use more sage. It won't mask your incompetence, but it will stop it from polluting the top of the page.

Name: Anonymous 2009-12-09 3:18

>>91
Sure is elitist around here.

Name: Anonymous 2009-12-09 5:43

ENTERPRISE C SOLUTION

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define f(x) for(i=(x)-1;i<n;i+=(x)) a[i]+=(x);
int main() {
  int i,b=3,a[100],n=sizeof(a)/sizeof(int);
  char *s="fizzbuzz ",*p,*m;
  memset(a,0,sizeof(a));
  f(b);
  b+=2;
  f(b);
  b--;
  for(i=0;i<n;i++)
    if(a[i]) {
      m = p = strdup(s);
      if(a[i]&8)
        goto pr;
      p+=(a[i]&4);
      p[b]=(!(a[i]&2))<<(b+1);
pr:
      printf("%s\n",p);
      free(m);
    }
    else
      printf("%d\n",i+1);
  return 0;
}

Name: Anonymous 2009-12-09 8:57

>>93
I came a little inside.

Name: Anonymous 2009-12-09 9:29

>>94
COME INSIDE MY ANUS

Name: Anonymous 2009-12-09 9:46

>>95
I tried but the door was locked!

Name: Anonymous 2009-12-09 9:52

>>92
Elitist? Fizzbuzz is practically the canonical "easy" program. Sage your stupid shit.

Name: Anonymous 2009-12-09 16:21

>>93

This is overconvoluted but not in a good way. It's not elegantly obfuscated. It's just... random. I wouldn't call it ENTERPRISE, that's certain.

OTOH understanding how it works is a better exercise than writing fizzbuzz in the first place.

That strdup/free pair in the main loop bothers me, next time move it outside and change p[b]=(!(a[i]&2))<<(b+1); to p[b]=(~(!(a[i]&2)*206))<<(b-3); or something.

Name: Anonymous 2009-12-09 16:30

>>98
yhbt

Name: Anonymous 2009-12-09 16:41

>>93
ioccc worthy

Name: Anonymous 2009-12-09 17:39

>>101 Now we are outside the range of fizzbuzz

Name: Anonymous 2009-12-09 17:40

>>101
This thread has been fizzbuzz stopped. You can't fizzbuzz anymore.

Name: Anonymous 2009-12-09 17:52

From now on you must write ``fizz'' if the number of post is divisible by 3, ``buzz'' if the number is divisible by 5, and ``fizzbuzz'' if it's divisible by 3 and 5.

Name: Anonymous 2009-12-09 18:14

104

Name: Anonymous 2009-12-09 18:15

FIZZBUZZ GET

Name: Anonymous 2009-12-09 19:17

106 now we are all part of fizzbuzz.prog

Name: Anonymous 2009-12-09 19:21

>>103
All numbers are divisible. fizzbuzz

Name: Anonymous 2009-12-09 19:32

FIZZ

Name: Anonymous 2009-12-09 19:46

BUZZ

Name: Anonymous 2009-12-09 20:00

>>109
expert fizz buzz player

FIZZ BUZZ

Name: Anonymous 2009-12-09 20:08

>>107
hail eris

Name: Anonymous 2009-12-09 21:12

>>111
HAIL MY ANUS

Name: Anonymous 2009-12-09 21:14

HAIL MY ERIS

Name: Anonymous 2009-12-09 22:59

All things happen in buzzs, or are divisible by or are multiples of buzz, or are somehow directly or indirectly appropriate to buzz.

Name: Anonymous 2009-12-09 23:35

>>114
The law of Buzz!

Name: Anonymous 2009-12-10 4:29

There's already a thread about this and every conceivable FizzBuzz implemntation has already been posted there.

Name: Anonymous 2009-12-10 4:44

>>116
CONCEIVE MY ANUS

Name: Anonymous 2009-12-10 4:57

>>116
orly?
i,j,k,l="fizz","buzz","fizzbuzz",1
while(l<101) do l = print(_G[("klliljillijlill"):sub(l%15+1,l%15+1)]) or l+1 end

Name: Anonymous 2009-12-10 9:04

int main() {
    for (int i = 1; i <= 100; ++i)
        fizzBuzz(i); // To be written by out intern
}

Name: Anonymous 2009-12-10 9:54


int main() {
    Boost::FizzBuzz<100>;
    return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List