>>6
Yep it's a perfect copy of the original post, but merely stripped of any already nonexistant readability.
Congratulations.
Name:
Anonymous2012-03-13 12:25
If it ain't fizzin', it's buzzin'.
Name:
Anonymous2012-03-13 13:16
Time for some benchmarks.
- GCC 4.6.3 -march=native -mtune=native -O3
- glibc 2.15
- Linux 3.2.9 SMP PREEMPT
- i5 2500K clocked at 3.30GHz
- stdout is /dev/null
- 50000000 iterations
- Programs are run two times and the best result is used.
>>1's fizzbuzz: real 0m3.034s
user 0m3.023s
sys 0m0.007s
My fizzbuzz: real 0m1.696s
user 0m1.677s
sys 0m0.017s
#include <stdio.h>
void fizzbuzz(unsigned int n)
{
char *s[] = {"%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n"};
unsigned int coarse = n >> 4;
unsigned int i = 1;
for (; coarse; coarse--) {
printf("%d\n"
"%d\n"
"Fizz\n"
"%d\n"
"Buzz\n"
"Fizz\n"
"%d\n"
"%d\n"
"Fizz\n"
"Buzz\n"
"%d\n"
"Fizz\n"
"%d\n"
"%d\n"
"FizzBuzz\n",
i, i + 1, i + 3, i + 6, i + 7, i + 10, i + 12, i + 13);
i += 15;
}
i--;
while (i++ < n)
printf(s[(!(i%3))|((!(i%5))<<1)], i);
}
int main(void) {
char arr[] = "%d\n%d\nfizz\n%d\nbuzz\nfizz\n%d\n%d\nfizz\nbuzz\n%d\nfizz\n%d\n%d\nfizzbuzz\n";
int news[]={0,3,6,11,14,19,24,27,30,35,40,43,48,51,54,63};
int i=N/15, j=1;
>>14 real 0m1.598s
user 0m1.587s
sys 0m0.007s
That's even better. It seems the <15times iteration at the end is actually a time eater!
Name:
Anonymous2012-03-13 16:32
BogoBuzz
Randomly generate a list of 100 elements, each element containing either: an int 1-100, "fizz", "buzz" or "fizzbuzz". Check if the result is correct. If correct, print out result. If not, start over.
Name:
Anonymous2012-03-13 16:45
So are you retards really timing I/O? Why don't you just allocate a single huge buffer and then write the entire thing to stdout at the end? It will be a lot faster and then you can jerk off since your implementation defined behavior is faster than someone else's.
Name:
Anonymous2012-03-13 16:58
>>17
now all I need is a quantum computer #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
GENERIC: say ( n -- )
M: integer say number>string print ;
M: fizz say drop "Fizz" print ;
M: buzz say drop "Buzz" print ;
M: f&b say drop "FizzBuzz" print ;