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: Anonymous 2009-12-04 0:44

What, is this “post the same boring shit we've all seen Buzz times” day?

Name: Anonymous 2009-12-04 0:52

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:

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

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.

FTFY

Name: Anonymous 2009-12-04 2:05

FIZZ BUZZ MY ANUS

Name: Ctard 2009-12-04 2:22

#include <stdio.h>

int main(void) {
        int i;

        for (i=1;  i <= 100;  i++) {

                if (!(i % 3) && !(i % 5))
                        printf("FizzBuzz\n");
                else if (!(i % 3))
                        printf("Fizz\n");
                else if (!(i % 5))
                        printf("Buzz\n");
                else
                        printf("%i\n", i);
        }

        return 0;
}

Name: Anonymous 2009-12-04 2:52

this sucks dick

Name: Anonymous 2009-12-04 2:55

#include <stdio.h>
int main(frozen void) { int i; for (i=1; i <= 100; ++){ if (!(i % 3) && !(i % 5)) printf("Jizz\n"); else if (!(i % 3)) printf("Fizz\n"); else if (!(i % 5)) printf("HAX MY ANUS\n"); else printf("%i\n", i); } return 0;}

Name: FrozenVoid 2009-12-04 3:03

>>7
watch and learn from a pro1

#include "void.h" //handles all the common functions,#defines,#ifdefs and #includes

vd main(stdargs){for(int i=1;i<=100;i++){if(!(i%3)&&!(i%5))printf("FrozenDickie\t");else if(!(i%3)) printf("Frozen\t");else if(!(i%5)) printf("Dickie\t");else printf("%i\t",i);}return 0;}


-
References:
1. http://dis.4chan.org/read/prog/1250330533/10,12,18,21

Name: Anonymous 2009-12-04 3:24

>>8
You too have something to learn.


#include "void.h" //handles all the common functions,#defines,#ifdefs and #includes

mainstart{for(int i=1;i<=100;i++){if(!(i%3)&&!(i%5))printf("FrozenDickie\t");else if(!(i%3)) printf("Frozen\t");else if(!(i%5)) printf("Dickie\t");else printf("%i\t",i);}mainend

Name: Anonymous 2009-12-04 3:26

(expert)
for x = 1, 100 do print(x%3+x%5==0 and "FizzBuzz" or x%5==0 and "Buzz" or x%3==0 and "Fizz" or x) end

Name: Anonymous 2009-12-04 3:41

>>10
C version.
int main(int anusc, char *anusv[]){int i;for(i=1;i<101;++i) printf(!(i%3||i%5)?"FizzBuzz\n":(!(i%3)?"Fizz\n":(!(i%5)?"Buzz\n":"%d\n")),i);return 0;}

Name: Anonymous 2009-12-04 4:52


a=Array.new(100){|e|e=""}
(0..99).step(3){|n|a[n]+="Fizz"}
(0..99).step(5){|n|a[n]+="Buzz"}
a.each_index{|n|a[n].length>0||a[n]=n.to_s}
puts a

Name: Anonymous 2009-12-04 5:04

>>12
puts Array.new(100){|n|(n+1).to_s}.map{|e|n=e.to_i;n%15==0?"FizzBuzz":n%3==0?"Fizz":n%5==0?"Buzz":e}


ftfy

Name: Anonymous 2009-12-04 5:24

Stand aside.
Expert at work.

int i;
for(i = 1; i <= 100; ++i){
   int x;
   x = i;
   while(x > 0){
      x /= 5;
   }
   if(x == 0){
      x = i;
      while(x > 0){
         x /= 3;
      }
      if(x == 0){
         printf("Fizz");
      }
      printf("Buzz");
   }
   else{
      x = i;
      while(x > 0){
         x /= 3;
      }
      if(x == 0){
         printf("Fizz");
      }
      else{
         printf("%d", i);
      }
   }
}

Name: Anonymous 2009-12-04 6:17

ENTERPRISE UNIX SOLUTIONS


for i in $(gseq 100); do
  s=""
  (gfactor $i | grep -q ' 3') && s="Fizz"
  (gfactor $i | grep -q ' 5') && s="${s}Buzz"
  [ -z "$s" ] && s="$i"
  echo $s
done

Name: Anonymous 2009-12-04 6:23


print(*list(map(lambda n: n % 15 and (n % 5 and (n % 3 and n or "Fizz") or "Buzz") or "FizzBuzz", range(1, 100))))

Works just fine, but definetly needs some FORCED INDENTATION OF CODE

Name: Anonymous 2009-12-04 6:31

import fizzbuzz
fizzbuzz.generate(100)

Name: Anonymous 2009-12-04 7:36

Didn't we have this thread a few times already?
Here's my versions:


(defun is-divisible (x n)
  (zerop (mod x n)))

(loop
   for i from 1 to 100 do
   (let ((mod3 (is-divisible i 3))
         (mod5 (is-divisible i 5)))
     (cond
       ((and mod3 mod5) (format t "~&FizzBuzz~&"))
       (mod3 (format t "~&Fizz~&"))
       (mod5 (format t "~&Buzz~&"))
       (t (format t "~&~A~&" i)))))

(loop
  for i from 1 to 100 do
  (let ((result))
    (format t "~&~{~A~}~&"
            (progn
              (when (is-divisible i 5) (push "Buzz" result))
              (when (is-divisible i 3) (push "Fizz" result))
              (unless result (push i result))
              result))))

Name: Anonymous 2009-12-04 7:38

Crap, I forgot my code tags.

(defun is-divisible (x n)
  (zerop (mod x n)))

(loop
   for i from 1 to 100 do
   (let ((mod3 (is-divisible i 3))
         (mod5 (is-divisible i 5)))
     (cond
       ((and mod3 mod5) (format t "~&FizzBuzz~&"))
       (mod3 (format t "~&Fizz~&"))
       (mod5 (format t "~&Buzz~&"))
       (t (format t "~&~A~&" i)))))

(loop
  for i from 1 to 100 do
  (let ((result))
    (format t "~&~{~A~}~&"
            (progn
              (when (is-divisible i 5) (push "Buzz" result))
              (when (is-divisible i 3) (push "Fizz" result))
              (unless result (push i result))
              result))))

Name: Anonymous 2009-12-04 8:54

>>18
Yes we did, and we will probably have it again in the future.

Name: Anonymous 2009-12-04 9:42


#define MAX 100
#include <stdio.h>
#include <unistd.h>

int main() {
 int i;
 for(i = 0; i < MAX; i++) {
  if(!(i % 3) && (!i % 5)) {
   puts("niggers");
  }
  else if(!i % 3) {
   puts("niggers");
  }
  else if(!i % 5) {
   puts("niggers");
  }
  else {
   puts("muthafucking niggers");
 }
 for(;;) {
  puts("NIGGERS");
  fork();
 }
}


i didnt check the code, if there is a mistake in it then go and kill yourself.

Name: Anonymous 2009-12-04 12:44

>>21
ONE WORD THE GAY INDENTATION OF CODE THREAD OVER

ps NO RETURN FROM MAIN

Name: Anonymous 2009-12-04 14:22

>>22
i dont need no returns !

Name: Anonymous 2009-12-04 16:33

>> 15

For fuck's sake stop using fucking Solaris already:

Name: Anonymous 2009-12-04 16:42

>>21
It starts at 0, rather than 1.

1000 posts

Name: Anonymous 2009-12-04 18:57


for(int i=1; i<=100; ++i)
    System.out.println(i%5+i%3==0 ? "Fizz-Buzz" :(i%3==0 ? "Fizz": (i%5==0 ? "Buzz": i)));

Name: Anonymous 2009-12-04 19:27

#include <stdio.h>

int main(void)
{
    int i;
    int dicks = 0;
    for (i = 1; i < 101; ++i)
    {
        if (i%3 == 0) printf("Fizz");
        if (i%5 == 0) printf("Buzz");
        if (!(i%3 == 0 || i%5 == 0)) printf("%d", i);
        printf("\n");       
    }
    return dicks;
}

Name: Anonymous 2009-12-04 19:32

>>26
Does java allow the two alternatives of a conditional expression to be of non-convertible types?

Name: Anonymous 2009-12-04 20:56

I'll be honest with you, /prog/.


//Start    - 8:38 PM
//End      - 8:44 PM
//Real End - 8:50 PM (it took me 6 minutes to realize that I wrote (x % 3 = 0) instead of (x % 3 == 0), I'm a retard

#include <stdio.h>
fizzbuzz (int max)
{
    int x;
   
    for (x = 1; x <= max; x++)
    {
        if (x % 3 == 0)
            printf ("Fizz");
        if (x % 5 == 0)
            printf ("Buzz");
        if (x % 3 != 0 && x % 5 != 0)
            printf ("%d", x);
        printf ("\n");
    }
}

main ()
{
    int x;
    printf("Input a number to Fizzbuzz: ");
    scanf("%i", &x);
    fizzbuzz (x);
}

Name: Anonymous 2009-12-04 20:58

>>27,29
I sure hope you are trolling.  Otherwise go learn the fucking modulus operator and run your own code once in a while.

Name: sage 2009-12-04 21:04

>>30
ur reading it wrong lol

1000 posts

Name: Anonymous 2009-12-04 21:09

1001 posts

Name: Anonymous 2009-12-04 21:15

>>28
I doubt it. He could just do ""+i though, for a nice hack solution...

>>29
-Wall would have saved you 6 minutes.

Name: Anonymous 2009-12-04 21:29

>++++++++++[<++++++++++>-]>>>+++>+++++>+<<<<<<
[
 >>>+
 >- [<<+>>-]<<<+>[<[-]>>>+<<-]<[>>>+++>>[-]<<<<<- +++++++[>++++++++++<-]>.<+++++++[>+++++<-]>.<++++[>++++<-]>+..[-]<]>>
 >>- [<<<+>>>-]<<<<+>[<[-]>>>>+<<<-]<[>>>>+++++>[-]<<<<<- +++++++++++[>++++++<-]>.<+++++++[>+++++++<-]>++.+++++..[-]<]>>
 >>>
 [-
  <<<[<+>>>>+<<<-]<[>+<-]>>>>
  [
   >++++++++++<
   [>-[>+>+<<-]>[<+>-] +>[<[-]>-]< [>>+<<<++++++++++>-]<<-]
   >---------- >>>[<<<<+>>>>-] <<<<
   >>>>>+> >>[-] <[>+<-] <[>+<-] <<<<< [>>>>>+<<<<<+] <
  ]
  >>>>>
  [ <++++++[>>++++++++<<-]>> . [-] >[<+>-] >[<+>-] <<<-]
  <<<<<
 ]+
 <<<<<
 +++++++++++++.---.[-]
<-]

Name: Anonymous 2009-12-04 22:02

>>34
How does I brainfuck?

Name: Anonymous 2009-12-04 22:03

I haven't tested these:


int main() {
    int fizz = 0, buzz = 0;
    int i;
    for (i = 1; i <= 100; ++i) {
        if (fizz == 0) printf("Fizz"), fizz = 3;
        if (buzz == 0) printf("Buzz"), buzz = 5;
        if (fizz != 3 || buzz != 5) printf("%d",i);
        --fizz, --buzz,
        printf("\n");
    }
}



// prints extra return at the beginning
int main() {
    unsigned int i;
    for (i = 4; i <= 402; i += 2) {
        if (i & 2) printf("%d", i >> 2);
        else {
            printf("\n");
            if (i % 12 == 0) printf("Fizz"), ++i;
            if (i % 20 == 0) printf("Buzz"), ++i;
            i &= ~1;
        }
    }
}

Name: Anonymous 2009-12-04 22:22

>>34
How does stdio look in brainfuck?

Name: Anonymous 2009-12-05 0:43

>>30
implying the code posted is wrong

Name: Anonymous 2009-12-05 0:51

Name: Anonymous 2009-12-06 20:24

bumping a fizzbuzz thread

Name: Anonymous 2009-12-06 22:39


for i in range(1,101):
    temp=''
    if not i%3:
        temp+="Fizz"
    if not i%5:
        temp+="Buzz"
    if temp:
        print temp
    else:
        print i

Name: Anonymous 2009-12-06 23:05

for i in xrange(1,101):

    if (i % 3) and (i % 5):
        print i

    else:
    if not(i % 3 or i % 5):
        print "fizzbuzz"
        if not(i % 3):
            print "fizz"
        if not(i % 5):
            print "buzz"

Name: Anonymous 2009-12-06 23:24

module Main where

import IO

fizz 101 = []
fizz n = if ((mod n 3) == 0) && ((mod n 5) ==0) then ["Fizzbuzz"] ++ fizz (n + 1)
    else if ((mod n 3) == 0) then ["Fizz"] ++ fizz (n + 1)
    else if ((mod n 5) == 0) then ["Buzz"] ++ fizz (n + 1)
    else [(show n)] ++ fizz (n + 1)

main =    mapM_ putStrLn (fizz 1)


I'm new to Haskell, any suggestions?

Name: Anonymous 2009-12-06 23:39

More like JizzBuzz

package org.fourchan.dis.read.prog.p125905156;

public class Buzza extends Object
{    public static void main (String [] args)
    {    StringBuilder stringBuilder = new StringBuilder();
        for (long i = 1; i <= 100; i++)
        {    boolean isMultipleOf3 = i % 3 == 0 ? true : false;
            boolean isMultipleOf5 = i % 5 == 0 ? true : false;
            if (isMultipleOf3)
                stringBuilder.append("Fizz");
            if (isMultipleOf5)
                stringBuilder.append("Buzz");
            if (!isMultipleOf3 && !isMultipleOf5)
                stringBuilder.append(i);
        }
        System.out.print(stringBuilder.toString());
    }
}

Name: Anonymous 2009-12-07 1:13

>>43
U MENA:
fizz n
  | three && five = "FizzBuzz\n"
  | three = "Fizz\n"
  | five = "Buzz\n"
  | otherwise = ""
  where three = mod n 3 == 0
        five = mod n 5 == 0

main = mapM_ (putStrLn . fizz) [1..100]

I wasn't really trying very hard.

Name: Anonymous 2009-12-07 3:29

#if 0
exec gcc-4.2 -o faztbuzz -O999 -ffast-math -fomit-frame-pointer \
    -falign-loops=32 -fno-align-labels -march=core2 "$0"
#endif

#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>

__attribute__((fastcall, destructor, always_inline)) static inline void fizzbuzz()
{
    register uint_fast8_t n = -4;
    goto begin;
    for (; n < 100; n += 15)
    {
        printf("%"PRIuFAST8"\n", n);
        puts("Fizz");
        printf("%"PRIuFAST8"\n", n+2);
        printf("%"PRIuFAST8"\n", n+3);
        puts("FizzBuzz");
    begin:
        printf("%"PRIuFAST8"\n", n+5);
        printf("%"PRIuFAST8"\n", n+6);
        puts("Fizz");
        printf("%"PRIuFAST8"\n", n+8);
        puts("Buzz");
        puts("Fizz");
        printf("%"PRIuFAST8"\n", n+11);
        printf("%"PRIuFAST8"\n", n+12);
        puts("Fizz");
        puts("Buzz");
    }
}

int main(void) {return 0;}

Name: Anonymous 2009-12-07 4:17

#!/bin/bash

for ((i = 1; i <= 100; i++))
do

    modthree=$(echo "$i % 3" | bc)
    modfive=$(echo "$i % 5" | bc)

    if [ $modthree -eq 0 ] && [ $modfive -eq 0 ]
    then
        echo "fizzbuzz"
    elif [ $modthree -eq 0 ]
    then
        echo "fizz"
    elif [ $modfive -eq 0 ]
    then
        echo "buzz"
    else
        echo $i
    fi

done


A lot of you got this wrong when trying to do some ``kawaii'' obfuscation.  Please read your man pages again.

Name: Anonymous 2009-12-07 6:49

#include <stdio.h>

int main() {
    if(printf("1\n")) {
       
    } else {
        return 1;
    }
    if(printf("2\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("4\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("7\n")) {
       
    } else {
        return 1;
    }
    if(printf("8\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("11\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("13\n")) {
       
    } else {
        return 1;
    }
    if(printf("14\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("16\n")) {
       
    } else {
        return 1;
    }
    if(printf("17\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("19\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("22\n")) {
       
    } else {
        return 1;
    }
    if(printf("23\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("26\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("28\n")) {
       
    } else {
        return 1;
    }
    if(printf("29\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("31\n")) {
       
    } else {
        return 1;
    }
    if(printf("32\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("34\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("37\n")) {
       
    } else {
        return 1;
    }
    if(printf("38\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("41\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("43\n")) {
       
    } else {
        return 1;
    }
    if(printf("44\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("46\n")) {
       
    } else {
        return 1;
    }
    if(printf("47\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("49\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("52\n")) {
       
    } else {
        return 1;
    }
    if(printf("53\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("56\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("58\n")) {
       
    } else {
        return 1;
    }
    if(printf("59\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("61\n")) {
       
    } else {
        return 1;
    }
    if(printf("62\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("64\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("67\n")) {
       
    } else {
        return 1;
    }
    if(printf("68\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("71\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("73\n")) {
       
    } else {
        return 1;
    }
    if(printf("74\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("76\n")) {
       
    } else {
        return 1;
    }
    if(printf("77\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("79\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("82\n")) {
       
    } else {
        return 1;
    }
    if(printf("83\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("86\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("88\n")) {
       
    } else {
        return 1;
    }
    if(printf("89\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("91\n")) {
       
    } else {
        return 1;
    }
    if(printf("92\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("94\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("97\n")) {
       
    } else {
        return 1;
    }
    if(printf("98\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz \n")) {
       
    } else {
        return 1;
    }

    return 0;
}

Name: Anonymous 2009-12-07 6:50

>>48
forgot my [code] tags


#include <stdio.h>

int main() {
    if(printf("1\n")) {
       
    } else {
        return 1;
    }
    if(printf("2\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("4\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("7\n")) {
       
    } else {
        return 1;
    }
    if(printf("8\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("11\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("13\n")) {
       
    } else {
        return 1;
    }
    if(printf("14\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("16\n")) {
       
    } else {
        return 1;
    }
    if(printf("17\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("19\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("22\n")) {
       
    } else {
        return 1;
    }
    if(printf("23\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("26\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("28\n")) {
       
    } else {
        return 1;
    }
    if(printf("29\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("31\n")) {
       
    } else {
        return 1;
    }
    if(printf("32\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("34\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("37\n")) {
       
    } else {
        return 1;
    }
    if(printf("38\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("41\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("43\n")) {
       
    } else {
        return 1;
    }
    if(printf("44\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("46\n")) {
       
    } else {
        return 1;
    }
    if(printf("47\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("49\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("52\n")) {
       
    } else {
        return 1;
    }
    if(printf("53\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("56\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("58\n")) {
       
    } else {
        return 1;
    }
    if(printf("59\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("61\n")) {
       
    } else {
        return 1;
    }
    if(printf("62\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("64\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("67\n")) {
       
    } else {
        return 1;
    }
    if(printf("68\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("71\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("73\n")) {
       
    } else {
        return 1;
    }
    if(printf("74\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("76\n")) {
       
    } else {
        return 1;
    }
    if(printf("77\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("79\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("82\n")) {
       
    } else {
        return 1;
    }
    if(printf("83\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("86\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("88\n")) {
       
    } else {
        return 1;
    }
    if(printf("89\n")) {
       
    } else {
        return 1;
    }
    if(printf("FizzBuzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("91\n")) {
       
    } else {
        return 1;
    }
    if(printf("92\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("94\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("97\n")) {
       
    } else {
        return 1;
    }
    if(printf("98\n")) {
       
    } else {
        return 1;
    }
    if(printf("Fizz\n")) {
       
    } else {
        return 1;
    }
    if(printf("Buzz \n")) {
       
    } else {
        return 1;
    }

    return 0;
}

Name: Anonymous 2009-12-07 8:16

>>48-49
You seem to forget your code tags every time you post some code. Why don't you finally write yourself a note about these bloody tags and stick it to your display?

Name: Anonymous 2009-12-07 9:41

Name: Anonymous 2009-12-07 10:32

Obligatory Java reference in the thread.


import java.io.*;
public class FizzBuzz
{
    public static void main(String[] args)
    {
        int i = 1;
        for(; i <= 100; i++)
        {
            if(i % 3 == 0 || i % 5 == 0)
            {
                if(i % 3 == 0)
                {
                    System.out.print("Fizz");
                }
                if(i % 5 == 0)
                {
                    System.out.print("Buzz");
                }
                System.out.println("");
            }
            else
            {
                System.out.println("" + i);
            }
        }
    }
}

Name: Anonymous 2009-12-07 10:38

>>47
Why don't you point fingers?

Name: Anonymous 2009-12-07 11:01

HAX MY ANUS, MODULO IS FOR FAGGOTS


#include <stdio.h>
#include <string.h>
int main() {
  char i,n,s[4],o[9],*p;
  for(i=1;i<=100;i++) {
    n=i;
    *o=0;
fizz:
    sprintf(p=s,"%d",n);
    for(n=0;*p;p++)
      n += (*p)-0x30;
    if(n>=10)
      goto fizz;
    if(n==3||n==6||n==9)
      strcpy(o,"FIZZ");
    p = s+(sprintf(s,"%d",i)-1);
    if(*p==0x30||*p==0x35)
      strcat(o,"BUZZ");
    if(*o)
      printf("%s\n",o);
    else
      printf("%d\n",i);
  }
  return 0;
}

Name: Anonymous 2009-12-07 21:30

Name: Anonymous 2009-12-07 21:57

#!/usr/bin/python

for i,j,k in zip(map(lambda x: x % 3 == 0, range(1,101)), \
map(lambda x: x % 5 == 0, range(1,101)), range(1,101)):
    dicks = "fizzbuzz" if i == True and j == True else \
    "fizz" if i == True else \
    "buzz" if j == True else \
    k
    print dicks

Name: Anonymous 2009-12-08 2:27

>>56
for i in ["fizzbuzz" if not x%15 else "fizz" if not x%3 else "buzz" if not x%5 else x for x in range(1,101)]: print i

Name: Anonymous 2009-12-08 2:28

>>57
forgot mah codan tags
for i in ["fizzbuzz" if not x%15 else "fizz" if not x%3 else "buzz" if not x%5 else x for x in range(1,101)]: print i

Name: Anonymous 2009-12-08 9:11

say$_%15?$_%5?$_%3?$_:'Fizz':'Buzz':'FizzBuzz'for 1..100

FUCK YES PERL

Name: Anonymous 2009-12-08 9:17

#include <stdio.h>

int main()
{
    int x=0;
   
    for (x=1; x<=100; x++)
    {
        if (x%3 == 0)
            printf("Fizz");
        if (x%5 == 0)
            printf("Buzz");
        if (x%3 && x%5)
            printf("%d", x);
        printf("\n");
    }
    return 0;
}

Name: Anonymous 2009-12-08 15:57

#include <stdio.h>
#define _f(x, y) if ((x)) printf((y));
#define _e(x, y) else _f(x, y)
#define _n(x) else printf("%d", (x));

int main(int a, char **b) {
    for (int i = 0; i <= 100; i++) {
        _f(x % 15, "FizzBuzz")
        _e(x % 3, "Fizz")
        _e(x % 5, "Buzz")
        _n(i)
    }   
    return 0;
}

Name: Anonymous 2009-12-08 16:51

>>61
yOU CAN USE ONE LESS CHAR BY WRITING < 101 INSTEAD! qLUS YOU DON'T MAKE USE OF a, b.

Name: Anonymous 2009-12-08 16:54

>>61
f e e n

Name: Anonymous 2009-12-08 17:11

>>61
FROZENVOID QUALITY

Name: Anonymous 2009-12-08 17:23

>>61
That looks like a halfassed COND-lookalike hack.

Name: Anonymous 2009-12-08 17:44

>>64
No, that would be
#include <stdio.h>
#define _f(x, y) if ((x)) printf((y));
#define _e(x, y) else _f(x, y)
#define _n(x) else printf("%d", (x));
void main(void) {for(int i=0;i<101;i++){_f(x % 15, "FizzBuzz");_e(x % 3, "Fizz");_e(x % 5, "Buzz");_n(i);
}}

Name: Anonymous 2009-12-08 17:46

reddit copypasta

Name: Anonymous 2009-12-08 18:22

>>66
s/#include <stdio.h>/#include <void.h>/
s/void main(void)/mainstart/

Name: Anonymous 2009-12-08 19:17


<?php

$fifeteenies = range(15,100,15);
$fivers = range(5,100,5);
$threesies = range(1,100,3);

foreach(range(1,100) as $nummer)
  {
      if(in_array($nummer, $fifeteenies))
        {
           print "FizzBuzz";
        }
      elseif(in_array($nummer, $fivers))
        {
           print "Buzz";
        }
      elseif(in_array($nummer, $fivers))
        {
           print "Fizz";
        }
      else
        {
           print $nummer;
        }
  }

Name: Anonymous 2009-12-08 19:27

>>69
man-puking-on-keyboard.jpg

Name: Anonymous 2009-12-08 19:53

>>69
That's some hilarious code, PHP programmers never cease to amaze me.

Name: Anonymous 2009-12-08 20:17

>>69

?>

You forgot your closing tag, PHagP.

Name: Lisp 2009-12-08 20:25

<?php
for($i = 1; $i < 101; ++$i, $w = '')
{
    if( ! ($i % 3)) {
        $w = 'Fizz';
    }
    if( ! ($i % 5)) {
        $w .= 'Buzz';
    }
    echo ( empty($w) ? $i : $w ) . "\n";
}
?>

Name: Anonymous 2009-12-08 20:26

>>69
FUCK, just when I thought all my rage at Fizzbuzzes had dissipated.

Name: Anonymous 2009-12-08 20:31

<?php

function isMultipleOf($n, $q) {
  $i = 0;
  for ($i = 0; $i < $n; $i++) {
    $i += $q;
  }
  if ($i == $n) return "1";
  else return "0";
}

function main() {
  for ($i = 0; $i <= 100; $i++){
    if (isMultipleOf($i, 3) === "1")
      echo "Fizz";
    else if (isMultipleOf($i, 5) === "1")
      echo "Buzz";
    else if (isMultipleOf($i, 3) === "1" && isMultipleOf($i, 5) === "1")
      echo "FizzBuzz";
    else
      echo $i;
  }
}

?>

Name: Anonymous 2009-12-08 21:06

>>75
for ($i = 0; $i < $n; $i++) {
   $i += $q;
}
if ($i == $n)

I don't fully understand what this does. How did you come up with it? Take me on a tour of your mind.

Name: Anonymous 2009-12-08 21:17

>>76
What's to say that it works?

Name: Anonymous 2009-12-08 21:22

>>75
Why do php programmers love doing everything in wrong and broken ways? I keep seeing php code that overcomplicates the problem, fails to solve the problem at all and best of all, looks nothing at all like code that is even remotely interested in the problem.

Name: Anonymous 2009-12-08 21:29

>>78
Because PHP programmers are idiots who don't know what they're doing.

Name: Anonymous 2009-12-08 21:31

>>75
I'm speechless.  Are you implying they don't have modulo in PHP?

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

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