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

MOST OPTIMIZED FIZZBUZZ IMPLEMENTATION

Name: Anonymous 2012-01-29 13:27

ever. (for any arbitery n)

#include <stdio.h>
 
#define N 100
 
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;
 
  while(i--){
   printf(arr, j, j+1, j+3, j+6, j+7, j+10, j+12, j+13);
   j+=15;
  }
  arr[news[N%15]]='\0';
  printf(arr, j, j+1, j+3, j+6, j+7, j+10, j+12, j+13);
 
  return 0;   
}

Name: Anonymous 2012-01-29 14:28

>>2
We already had many Fizzbuzz threads, I'm not going to point you to them. The reason I said "Nope" is because anyone who understands basic CS knows that Kolmogorov complexity of a string (such as the final FizzBuzz output) is uncomputable, although I suppose one can get good approximations for specific machines if they're willing to do a lot of specific mathematical proofs (usually mechanized). In a bit more general terms, no perfect optimizing compiler can exists as well: http://en.wikipedia.org/wiki/Full_employment_theorem
No more than an universal halting problem solver (although specific-case can be done, and possibly self-improving as well, although it's provable that there will always be programs you won't be able to decide, just like there will always be arithmetical truths that won't be reachable by proofs, by Godel's incompleteness theorem).

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