Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

> Fizz Buzz, any languages

views
     
sunsuron
post May 19 2007, 01:38 AM

Regular
******
Senior Member
1,334 posts

Joined: Nov 2004



I guess, if your main intention was to get the shortest, then it is not cheating. I have a few C collections not long time ago, exam preparation for a job interview just in case. Hehe. biggrin.gif

CODE

main(){char i=0,n[3];while(i++<100)printf("%s%s%s\n",i%3?"":"Fizz",i%5?"":"Buzz",(i%3&&i%5&&sprintf(n,"%d",i))?n:"");}


CODE

main(){int i=0;while(i++<100)(i%3||!printf("Fizz"))*(i%5||!printf("Buzz"))&&printf("%d",i),printf("\n");}


CODE

#include <stdio.h>
static const char *t[] = {"%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n"};
int main()
{
 unsigned int i;
 for(i = 1; i <= 100; i++) printf(t[3&19142723>>2*i%30], i);
 return 0;
}

sunsuron
post May 23 2007, 01:52 AM

Regular
******
Senior Member
1,334 posts

Joined: Nov 2004



Glad u ask. Here are what everybody think about that kind of solution:
  • that wouldn't work
  • it's a literal - it means the number of flying monkeys.
  • magic-numbers are _always_ a mistake.
  • right.
  • whatever that means, it's fscking ridiculous.
  • let's do fizzbuzz contest!
  • maybe something like this may solve (i % 3) ? ( i % 5 ) ? FizzBuzz : Fizz : i ; (i % 5) ? (i % 3) ? FizzBuzz : Buzz : i
  • we always welcome interesting questions about C++, you don't need to ask if you can ask them. Additionally, if you wish to avoid being made fun of, read http://jcatki.no-ip.org/fncpp/HowToGetBetterHelp and http://www.catb.org/~esr/faqs/smart-questions.html.
  • oops sorry, that would work yes
  • that's a difficult problem
  • let's use geordi
  • Green potatoes?
Anyway, the author is Samuel Tardieu. See here.

This post has been edited by sunsuron: May 23 2007, 01:55 AM

 

Switch to:
| Lo-Fi Version
0.0180sec    0.25    6 queries    GZIP Disabled
Time is now: 30th March 2020 - 06:34 AM