Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

> Fizz Buzz, any languages

views
     
zybler
post May 18 2007, 08:23 PM

Casual
***
Junior Member
404 posts

Joined: Jan 2003


QUOTE(seraphiel @ May 18 2007, 09:55 AM)
Well, since you specifically said interesting here's mine:

CODE
<?foreach(range(1,100)as$i)echo$i%15?$i%5?$i%3?$i:"Fizz":"Buzz":"FizzBuzz","\n";?>


I actually posted about it here (and included a couple of solutions my colleagues came up with) whistling.gif
*
Nice try, here's 67 chars one smile.gif :

CODE
<?while($i++<100)echo$i%3?$i%5?$i:'':'Fizz',$i%5?'':'Buzz',"<br>"?>




This post has been edited by zybler: May 18 2007, 08:26 PM
zybler
post May 18 2007, 09:51 PM

Casual
***
Junior Member
404 posts

Joined: Jan 2003


QUOTE(seraphiel @ May 18 2007, 09:33 PM)
I've been coding with error_reporting(E_ALL) too long to even attempt that, zybler tongue.gif

I would say that your solution is definitely not what I'd accept as the shortest simply because it throws a warning whistling.gif
*
If you so insists on using it on error_reporting(E_ALL) mode, then here it is:

CODE
<?$i=0;while($i++<100)echo$i%3?$i%5?$i:'':'Fizz',$i%5?'':'Buzz',"\n"?>


Still shorter than yours by 12 bytes, laugh.gif.
zybler
post May 18 2007, 11:08 PM

Casual
***
Junior Member
404 posts

Joined: Jan 2003


Tried it in C. With suggestion by a close friend, managed to push it down to 109 chars.

CODE
main(){char n[4];int i;for(;i++<100;){sprintf(n,"%d",i);printf("%s%s\n",i%3?i%5?n:"":"Fizz",i%5?"":"Buzz");}}


Kinda feel like cheating: no #include<stdio.h> no return type for main and no return in main. The strange thing though, it runs!

This post has been edited by zybler: May 18 2007, 11:12 PM

 

Switch to:
| Lo-Fi Version
0.0206sec    0.08    6 queries    GZIP Disabled
Time is now: 5th April 2020 - 05:40 AM