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

90% of /prog/ can't write FizzBuzz

Name: The antagonist 2008-04-25 12:38

Prove me wrong

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

Name: Anonymous 2008-05-05 21:46

>>200
One less.

mapM_(\x->putStrLn$["FizzBuzz","Buzz","Fizz",show x]!!(signum(x`mod`3)+signum(x`mod`5)*2))[1..100]

Name: Anonymous 2008-05-05 22:04

>>201
6 less:

mapM_(\x->putStrLn$["FizzBuzz","Buzz","Fizz",show x]!!on((+).(*2))(signum.mod x)5 3)[1..100]

Name: Anonymous 2008-05-05 22:13

Haskell can't do this of course.
hahaha FAIL.

Name: Anonymous 2008-05-06 8:24


mapM_(\x->putStrLn$case gcd x 15 of 1->show x;3->"Fizz";5->"Buzz";15->"FizzBuzz")[1..100]

Name: Anonymous 2008-05-06 9:20

i lol'd. haskell golf

Name: Anonymous 2008-05-06 9:47

>>205
ha ha I get this

Name: Anonymous 2008-05-06 9:53

lol scalable

mapM_(\x->putStrLn$maximum([concatMap(\(n,s)->[s,""]!!signum(x`mod`n))[(3,"Fizz"),(5,"Buzz")],show x]))[1..100]

Name: Anonymous 2008-05-06 10:05

Name: Anonymous 2008-05-06 15:57

>>207
mapM_(\x->putStrLn$max(show x)$concatMap(\(n,s)->[s,""]!!signum(x`mod`n))[(3,"Fizz"),(5,"Buzz")])[1..100]

Name: Anonymous 2008-05-06 16:52

This one is actually from http://hpaste.org/93, but seemed worth posting:

mapM_ putStrLn[cycle[show n,"Fizz","Buzz","FizzBuzz"]!!div(gcd n 15)2|n<-[1..100]]

Name: Anonymous 2008-05-06 20:15

>>210
that is nice

Name: Anonymous 2008-05-06 20:19

>>210
Agreed, very clever. Bravo.

Name: Anonymous 2008-05-06 23:36


mapM_ putStrLn[max(show x)$f++b|f<-cycle[[],[],"Fizz"]|b<-cycle[[],[],[],[],"Buzz"]|x<-[1..100]]

Name: Anonymous 2008-05-07 18:51

#include "IOstream.h"

void Main(int argc, char[][] agv) {
 int num= 0;
start:
 if(num = 100) {
   goto end;
 }
 if (num < 100) {
   num= num +1;
 }

// print section
 if (num % 3 = 0) {
   cout<< "fizz";
 }
 if (num % 5= 0) {
  cout<< "buzz;"
 }
 if (num %3= 0) {
   if (num%5 =0) {
     cout << "fizzbuzz";
   }
 }
 goto start;


}

Name: Anonymous 2008-05-07 18:52

>>1
heh. ha ha. HA. HA HA HA. AH HAHAHAHAHAHAHA, OH GOD AH HAHAHAHAHAHAHAHA. BUHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHa....

Oh... oh...


That's a good one.

Name: Anonymous 2008-05-07 19:12

#light

let modcheck y =
    match y with
    | _ when y % 3 + y % 5 = 0 -> printfn "FizzBuzz"
    | _ when y % 5 = 0 -> printfn "Buzz"
    | _ when y % 3 = 0 -> printfn "Fizz"
    | _ -> printfn "%d" y
   
let fizzbuzz =
    let range = seq {1 .. 100}
    range |> Seq.iter modcheck

fizzbuzz



(F#)

Name: Anonymous 2008-05-07 19:41

>>216
[/code]
That syntax looks
|_Absolutely
   |_Horrid
[/code]

Name: Anonymous 2008-05-07 19:42

>>217
Don't you fucking dare talk about ML syntax like that.

Name: Anonymous 2008-05-07 19:47

>>217
//fixed it

let fizzbuzz =
    let range = seq {1 .. 100}
    let modcheck y =
        match y with
        | _ when y % 3 + y % 5 = 0 -> printfn "FizzBuzz"
        | _ when y % 5 = 0 -> printfn "Buzz"
        | _ when y % 3 = 0 -> printfn "Fizz"
        | _ -> printfn "%d" y
    range |> Seq.iter modcheck
  

//F# is beautiful so fuck off, every other piece of code in this thread is pretty much the same level of readability or worse.

Name: Anonymous 2008-05-07 19:51


#include <stdio.h>
int main(void)
{
    for(int i=1; i<=100; i++) {
        if(i % 3 == 0) {
            printf("Fizz");
            if(i % 5 == 0) printf("Buzz");
        } else if(i % 5 == 0) printf("Buzz");
        else printf("%d", i);
        printf("\n");
    }
    return 0;
}

Name: Anonymous 2008-05-07 21:26


/over { 1 index } bind def

/fizzBuzz {
  1 1 100 {
    dup  3 mod 0 eq dup { (Fizz) print } if
    over 5 mod 0 eq dup { (Buzz) print } if or
    { pop () } if =
  } for
} bind def

fizzBuzz quit

Name: Anonymous 2008-05-08 4:01

>>219
I, as a Haskellite, came. This is the most beautiful syntax ever.

Name: Anonymous 2008-05-08 4:32


.data
Fizz:    .asciiz "Fizz"
Buzz:    .asciiz "Buzz"
.text                   
main:
    xor    $s1, $s1, $s1
    ori    $t1, $0, 0x64
    ori    $t3, $0, 0x3
    ori    $t5, $0, 0x5
    ori    $t6, $0, 0xF
FizzBuzz:
    addi    $s1, $s1, 1
    xor    $s2, $s2, $s2
    div    $s1, $t3
    mfhi    $t2
    bne    $t2, $0, zziF
    la    $a0, Fizz
    ori    $v0, $0, 4
    syscall
    ori    $s2, $s2, 1
zziF:    div    $s1, $t5
    mfhi    $t2
    bne    $t2, $0, zzuB
    la    $a0, Buzz
    ori    $v0, $0, 4
    syscall
    ori    $s2, $s2, 1
zzuB:    bne    $s2, $0, zzuBzziF
    or    $a0, $0, $s1
    ori    $v0, $0, 1
    syscall
zzuBzziF:   
    bne    $s1, $t1, FizzBuzz
    li      $v0,  10
    syscall

Name: Anonymous 2009-03-06 6:01


inclusive Display your results   in a tabular   format similar to   the one im.

Name: Trollbot9000 2009-07-01 9:19

Have to relearn and that little things.

Name: Anonymous 2009-08-16 1:46

Lain.

Name: Anonymous 2009-08-16 2:14

Lain.

Name: Anonymous 2009-08-16 2:35

Lain.

Name: Anonymous 2009-08-16 3:08

Lain.

Name: Anonymous 2009-08-16 3:20

Lain.

Name: Anonymous 2009-08-16 3:38

Lain.

Name: Anonymous 2009-08-16 3:50

Lain.

Name: Anonymous 2009-08-16 3:52

Lain.

Name: Anonymous 2009-08-16 6:30

Lain.

Name: Anonymous 2009-08-16 12:28

// Code is in C#

for(int i=1; 1<100; i++)
{
String text;

if((i%5)!= 0 && (i%3) != 0)
text += Convert.ToString(i);

if((i%3) == 0)
text += "Fizz";

if((i%5)==)
text += "Buzz";

Console.Write(text);

Name: Anonymous 2009-08-16 12:29

>>235
Please use [code] tags in the future

Name: Anonymous 2009-08-16 12:52


TESTICLES
if(fuck=true)
hax butthax butthax butthax butthax butthax butthax butthax butthax butthax butthax butthax butthax butthax butthax butt

Name: Anonymous 2009-08-16 13:08

Name: Anonymous 2009-08-16 19:01

fizzBuzz = mapM_ putStrLn $ map f [1..100]
  where
    f n | m3 n && m5 n = "FizzBuzz"
        | m3 n = "Fizz"
        | m5 n = "Buzz"
        | True = show n
    m3 n = mod n 3 == 0
    m5 n = mod n 5 == 0

Name: Anonymous 2009-08-16 21:42

>>239
Perhaps you should have read the thread before posting redundant Haskell solutions. Also, use [code] tags, damn it!

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