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

Pages: 1-

fizz buzz

Name: Anonymous 2011-10-15 16:47

I have achieved my lifelong dream. Finally a fizz buzz program with 0 comparison operator.

#include <stdio.h>
#include <stdlib.h>

void main(int j){
  const char* s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
  printf(s[3-!!(j%3)-2*!!(j%5)], j);
  (main+((exit-main)*(j/100)))((1-j/100)*j+1);
}

Name: Anonymous 2011-10-15 17:01

NOT OPTIMIZED ENOUGH

Name: Anonymous 2011-10-15 17:03

>>2

#include <stdio.h>
#include <stdlib.h>

void main(int j){
  const char* s[] = {"%d\n","fizz\n","buzz\n","fizzbuzz\n"};
  printf(s[3-!!(j%3)-2*!!(j%5)], j);
  (main+((exit-main)*(j/100)))((1-j/100)*j+1);
}


ZOMG OPTIMIZED

Not really, ``faggot''

Name: Anonymous 2011-10-15 17:22

>>1
Faggot-tier.

delan@pluto:/tmp$ cc -o fb2 fb2.c -Wall -Werror -Wextra -pedantic -ansi
cc1: warnings being treated as errors
fb2.c:4: error: return type of ‘main’ is not ‘int’
fb2.c:4: error: ‘main’ takes only zero or two arguments
fb2.c: In function ‘main’:
fb2.c:7: error: pointer to a function used in subtraction
fb2.c:7: error: pointer to a function used in arithmetic

Name: Anonymous 2011-10-15 17:34

This is damn ugly code, but it compiles with utmost stringency:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uintptr_t p;
int e(int a, char **b) { char **c;c=b;exit(a); }
int main(int a, char **b) {
        char *s
[] = {"%d", "fizz", "buzz", "fizzbuzz"},**c;
        c=b;
        printf(s
[(!(a%3))|((!(a%5))<<1)], a);
        putchar(10);
        return (*((int(*)(int,char**))((((p)main)+((p)e-(p)main)*(a/100)))))(a+1,NULL);
}


delan@pluto:/tmp$ cc -o fb fb.c -Wall -Werror -Wextra -pedantic -ansi
delan@pluto:/tmp$ ./fb
(correct output redacted)

Name: Anonymous 2011-10-15 17:40

I've never understood why anyone would willingly choose the -pedantic flag. It's almost as if they've never looked up the meaning of the word.

Name: Anonymous 2011-10-15 17:40

>>4
use a compiler that has balls

Name: Anonymous 2011-10-15 18:23

See:

http://codepad.org/T1grqp7Z

Final code:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uintptr_t p;
char *s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
int e(int i, char **j) {
    int k;
    char **l;
    k = i;
    l = j;
    exit(0);
}
int main(int i, char **j) {
    char **k;
    k = j;
    printf(s
[(!(i % 3)) | ((!(i % 5)) << 1)], i);
    (*((int (*)(int, char **))((p)(main) + ((p)(e) -
    (p)(main)) * (i / 100))))(i + 1, NULL);
    return 0;
}


Compiles, warning-free, with:

gcc -ansi -Wall -Werror -Wextra -pedantic

Name: Anonymous 2011-10-15 18:37

>>8
why so many unnecessary assignment operators on last code?

Name: Anonymous 2011-10-15 18:38

>>9
To inhibit the "j is unused" errors in e and main.

Name: Anonymous 2011-10-15 18:43

Name: Anonymous 2011-10-15 18:44

meh, could be more clean. move recursion to function "e"
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uintptr_t p;
char *s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
void e(int i) {
   
    printf(s[(!(i % 3)) | ((!(i % 5)) << 1)], i);
    (*((void(*)(int))((p)(e) + ((p)(exit) -
    (p)(e)) * (i / 100))))((1-i/100)*(i + 1));
}
int main() {
        e(1);
    return 0;
}

not sure if it is still warningless

Name: Anonymous 2011-10-15 18:49

>>12
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uintptr_t p;
char *s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
void r(int i) {
    printf(s[(!(i % 3)) | ((!(i % 5)) << 1)], i);
    (*((void (*)(int))((p)(r) + ((p)(exit) - (p)(r)) * (i / 100))))(i + 1);
}
int main() {
    r(1);
    return 0;
}

Name: Anonymous 2011-10-15 18:49

>>12
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
typedef uintptr_t p;
char *s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};
void r(int i) {
    printf(s[(!(i % 3)) | ((!(i % 5)) << 1)], i);
    (*((void (*)(int))((p)(r) + ((p)(exit) - (p)(r)) * (i / 100))))(i + 1);
}
int main() {
    r(1);
    return 0;
}


http://codepad.org/uGK89n5v

Name: Anonymous 2011-10-15 18:50

Name: Anonymous 2011-10-15 22:53

>>1
I wrote something like that a few years ago. The Asm output is amusing to read.

Name: Anonymous 2011-10-16 0:29

Congratulations, fag, you achieved something that I wrote in my spare time once because I was bored.

Name: Anonymous 2011-10-16 2:35

does this count?


#include<stdio.h>

char* s[] = {"%d\n", "fizz\n", "buzz\n", "fizzbuzz\n"};


class fizzbuzzer{
  public:
    fizzbuzzer() : i(1) {}
    fizzbuzzer& operator++() {
      printf(s[!(i % 3) | ((!(i % 5)) << 1)], i);
      ++i;
      return *this;
    }
    int i;
};

int main(int argc, char** argv) {
  fizzbuzzer f;
  ++++++++++++++++++++++++++++++++++++++++
  ++++++++++++++++++++++++++++++++++++++++
  ++++++++++++++++++++++++++++++++++++++++
  ++++++++++++++++++++++++++++++++++++++++
  ++++++++++++++++++++++++++++++++++++++++f;
}

Name: Anonymous 2011-10-16 6:40

>>18
nah, you could as well printf("1\n2\nfizz\n...

Name: Anonymous 2011-10-16 7:02

I did fizzbuzz in vim. here it is

i1<Esc>qqYp<C-A>q98@qkqqa Fizz<Esc>3kq32@qGqqA Buzz<Esc>5kq19@q:%s/z /z/g<CR>ZZ

Name: Anonymous 2011-10-16 7:02

I did fizzbuzz in vim. here it is

i1<Esc>qqYp<C-A>q98@qkqqa Fizz<Esc>3kq32@qGqqA Buzz<Esc>5kq19@q:%s/z /z/g<CR>ZZ

Name: Anonymous 2011-10-16 8:07

(define (ascend f a b)
  (call/cc (lambda (cc)
    (let ((lut (list f (lambda (n) (f n) (cc)))))
      (define (ascend-rec i)
        ((list-ref lut (floor (/ i (max a b)))) i)
        (ascend-rec (+ i 1)))
      (ascend-rec (min a b))))))

(define (fizzbuzz x)
   (let ((lut (list number->string
                    (lambda (x) "Fizz")
                    (lambda (x) "Buzz")
                    (lambda (x) "FizzBuzz"))))
     (display ((list-ref lut (- 3
                                (min 1 (modulo x 3))
                                (* 2 (min 1 (modulo x 5))))) x))
     (newline)))

(ascend fizzbuzz 1 50)

Name: Anonymous 2011-10-16 10:23

>>22
that's lame.


public interface Printable
{
  public void print();
}

public class Fizz implements Printable
{
  public void print()
  {
    System.out.print("Fizz");
  }
}

public class Buzz implements Printable
{
  public void print()
  {
    System.out.print("Buzz");
  }
}

public class FizzBuzz implements Printable
{
  public void print()
  {
    Fizz fizz = new Fizz();
    Buzz buzz = new Buzz();
    fizz.print();
    buzz.print();
  }
}

public class Main
{
  public static void main(String [ ] args)
  {
    for (int i = 0; i < 100; ++i)
    {
      Printable printIt = null;
      if (i % 3 == 0)
      {
        printIt = new Fizz();
      }
      if (i % 5 == 0)
      {
        printIt = new Buzz();
      }
      if (i % 5 == 0 && i % 3 == 0)
      {
        printIt = new FizzBuzz();
      }
      assert printIt != null : "TODO: JUnit tests";
      printIt.print();
      System.out.println(" ");
    }
  }
}

Name: Anonymous 2011-10-16 12:59

>>23
I lold

Name: Anonymous 2011-10-16 13:38

Now with support for output in columns!


%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 595 0 843

/string-buffer 100 string def

/messages [{string-buffer cvs show} {pop (fizz) show} {pop (buzz) show} {pop (fizzbuzz) show}] def

/page-width 596 def
/page-length 843 def
/number-of-lines 100 def

/number-of-columns 2 def
/column-width page-width number-of-columns div def

/number-of-lines-per-column number-of-lines number-of-columns div cvi def
/line-height page-length number-of-lines-per-column div cvi def

/Helvetica findfont line-height scalefont setfont

/program [{loop} {pop}] def

/loop {
  /line exch def

  line number-of-lines-per-column div cvi column-width mul
  page-length line-height line number-of-lines-per-column mod mul sub
    moveto

  line
  messages line 3 mod 2 div ceiling cvi line 5 mod 4 div ceiling cvi 2 mul add get
    cvx exec

  line 1 add
  program line 100 div floor cvi get
    cvx exec
} def

1 loop

Name: Anonymous 2011-10-16 15:51

(define (fizzbuzz) (fuckmyballs 0))                                                                             
(define fuckmyballs                                                                                             
  (lambda (niggar)                                                                                              
    (cond                                                                                                       
     ((eq? niggar 100) (print "fizzbozz"))                                                                      
     ((and (zero? (modulo niggar 3)) (zero? (modulo niggar 5)))                                                 
      (print "fizzbuzz") (fuckmyballs (+ 1 niggar)))                                                            
     ((zero? (modulo niggar 3))                                                                                 
      (print "fizz")(fuckmyballs (+ 1 niggar)))                                                                 
     ((zero? (modulo niggar 5))                                                                                 
      (print "buzz")  (fuckmyballs (+ 1 niggar)))                                                               
     (else (fuckmyballs (+ 1 niggar))))))

Name: Anonymous 2011-10-16 16:00

uh change that last line to (else (print niggar) (fuckmyballs (+ 1 niggar))))))

Name: Anonymous 2011-10-16 18:00

>>27
You can't make me.

Name: Anonymous 2011-10-16 18:56

#include <ooc/io/io.h>
#include <ooc/util/FizzBuzzGenerator.h>

int main (void) {
  var fb = new (FizzBuzzGenerator (), 1, 100);

  foreach (var v, fb) {
    println (v);
  } foreach_end;

  del (fb);

  return 0;
}

Name: Anonymous 2011-10-16 19:02

>>26
unreadable shit.

Name: Anonymous 2011-10-16 23:03

>>30
Faggot assed parens based language is ``faggot''!!!!

Name: Anonymous 2011-10-16 23:09

>>33 Hey noyce DUBZ, brohansen.

Name: Anonymous 2011-10-16 23:09

>>32 Hey, thanks, broseph

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