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

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

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