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-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?

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