Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Create the shortest possible obfuscated FizzBuzz implementation.

To be considered obfuscated, it should satisfy at least one of the following:

  1. Does not contain any of the words "Fizz", "Buzz", or "FizzBuzz"
  2. Does not contain the numbers 3, 5, or 15.
  3. Use any of the above in a misleading way.

Remember: The goal is to be short and hard to follow.

The code sample which inspired this question follows:

public class Default
{
        enum FizzBuzz
        {
            Buzz = 1,
            Fizz,
            FizzBuzz
        }
        public static void Main(string[] args)
        {
            byte[] foo = 
              Convert.FromBase64String("IAmGMEiCIQySYAiDJBjCIAmGMEiCIQySYA==");
            MemoryStream ms = new MemoryStream(foo);
            byte[] myByte = new byte[1];
            do
            {
                FizzBuzz fb;
                ms.Read(myByte, 0, 1);
                for (int i = 0; i < 4; i++)
                {
                    fb = (FizzBuzz)(myByte[0] >> (2 * i) 
                         & (int)FizzBuzz.FizzBuzz);
                    Console.Out.WriteLine( (((int)fb > 0) ? "" + fb : "" 
                         + ((ms.Position - 1) * 4 + i + 1)));
                }
            } while (ms.Position < ms.Length);
        }
}
share|improve this question

34 Answers 34

up vote 20 down vote accepted

GolfScript, 75 69 65 60 59 chars

100,{)6,{.(&},{1$1$%{;}{4*35+6875*25base{90\-}%}if}%\or}%n*

So, you'd think GolfScript by itself is already obfuscated, right? Well, just to follow the spec, I decided to have the program not contain "fizz", "buzz", nor the numbers 3, 5, nor 15. :-)

Yes, there are some numbers with multiples of 5, like 25, 35, 90, 100, and 6875. Are they red herrings? You decide. ;-)

share|improve this answer
1  
Although I've written commentary for all my other GolfScript submissions, none will be forthcoming for this one. Rationale: chat.stackexchange.com/transcript/message/436819#436819 :-D –  Chris Jester-Young Jan 31 '11 at 4:34

Javascript 97 chars - no numbers at all

Numbers ? Who needs number when you have Javascript !

a=b=!![]+![],a--,c=b+b;while(++a)e=!(a%(c+c+b)),alert(!(a%(c+b))?e?"FizzBuzz":"Fizz":e?"Buzz":a);

Note: There is an infinite loop that will alert you the sequence.

Bonus (666 chars)

  • No number
  • No letter (only zfor has been use in the whole script)

.

_=$=+!![];$__=((_$={})+'')[_+$+_+$+_];__$=((![])+'')[$];_$_=((_$={})+'')
[_+$+_+$+_+$];____=[][$__+((_$={})+'')[$]+(($)/(![])+'')[$]+$__+__$+_$_];$__$=(!![]+"")
[$+$+$]+([][(![]+"")[$+$+$]+(+[]+{})[$+$]+(!![]+"")[$]+(!![]+"")[+[]]]+"")[($+$)+""+
($+$+$)]+(![]+"")[$]+(![]+"")[$+$];$_$_=____()[$-$][$__$]("\"\\"+($)+($+$+$+$+$+$+$)+
($+$)+"\"");_$=(![]+'')[$-$]+([][[]]+[])[$+$+$+$+$]+$_$_+$_$_;$_=(_+{})[$+$+$]+(!![]+'')
[_+$]+$_$_+$_$_;_--,$$=$+$;____()[$-$][$__$]((![]+"")[+[]]+(+[]+{})[$+$]+(!![]+"")[$]+
"(;++_;)$$$=!(_%("+($$+$$+$)+")),____()[+[]][__$+((![])+'')["+($+$)+"]+((!![])+'')["+
($+$+$)+"]+((!![])+'')[+!![]]+_$_](!(_%("+($$+$)+"))?$$$?_$+$_:_$:$$$?$_:_);");
share|improve this answer
13  
+1 - The second one blows my mind. –  Kyle Rozendo Jan 28 '11 at 13:03
8  
Real programmers code just like the second one. –  user11 Jan 29 '11 at 11:57
5  
@M28: Yep. That's one way to build job security...'cause finding someone who can maintain this code wouldn't be the easiest thing. –  Andy Feb 2 '11 at 5:07
1  
You can use window["eval"]('"\\'+1+7+2+'"') for z. –  Nabb Feb 3 '11 at 2:25
2  
@stevether It's mostly about abusing type conversion (ex.: +!![] is the same as 1 and ({}+"")[5] is the same as c) and abusing array notation to access method (ex.: window['eval']( is the same eval( ). –  HoLyVieR Aug 19 '12 at 5:06

PostScript, 96 bytes

So obfuscated it looks like random garbage.

1<~0o0@eOuP7\C+tf6HS7j&H?t`<0f>,/0TnSG01KZ%H9ub#H@9L>I=%,:23M].P!+.F6?RU#I;*;AP#XYnP"5~>cvx exec

Usage: $ gs -q -dNODISPLAY -dNOPROMPT file.ps

share|improve this answer
2  
I bet that passes diehard. –  kaoD Feb 6 '13 at 4:27

Python - 78 chars

i=0
while 1:i+=1;print"".join("BzuzzizF"[::2*j]for j in(-1,1)if 1>i%(4+j))or i
share|improve this answer
    
Took me 10 minutes to understand what you did there. Nice and twisted. –  Trufa Jun 8 '11 at 15:04

C++: 886 chars

I've tried to hide the 'fizz' and the 'buzz'. Can you spot them?

#include <iostream>
#define d(a,b) a b
#define _(a,b) d(#b,#a)
#define b(b) _(b,b)
#define y _(i,f)c
#define x _(u,b)c
#define c b(z)
#define i int
#define p main
#define s char
#define q 810092048
#define h for
#define m 48
#define a ++
#define e ==
#define g 58
#define n 49
#define l <<
#define oe std::cout<<
#define v '\n'

int  p   (i,  s*t     ){i   j  =   q;h   (*(
i    *     )    t     =  m  ;  2     [     t
]?   0    :    1      ??(   t  ]    ?     a
1    [   t    ]       e  g  ?  1   [     t
]    =   48,  ++0     ??(    t]e   g?0   ??(

t]=  n   ,1[  t]=
2    [     t    ]
=m   :    1    :
1    :   a    0
[    t   ??)  ==g

?0[   t  ]   =49   ,1[
t  ]  =  m     :     1
;j=   (  j    /     4
)  |  (  (   j     &
3)l    28)   )oe   (j&

3?j  &   1?j  &2?
y    x     :    y
:x   :    t    )
l    v   ;    }
i    f   =m&  ~g;
share|improve this answer
2  
That confuzzlesing my brane. –  muntoo Mar 11 '11 at 3:17
    
I think you meant membrane –  Korvin Szanto Dec 14 '11 at 22:34

DC (256 255 bytes)

Here it is, I tried (rather successfully, if I may say so myself) to hide anything except for letters, and +-[];:= (which are vital and impossible to obfuscate). It does segfault after getting to about 8482 or so on my machine, but that is to do with stack issues related to the way the recursion is implemented. The solution itself is correct. 255 bytes if you remove the whitespace (included for ease of reading) Enjoy:

Izzzdsa+dsbrsc+dsdd+sozdsezzsm+s
nloddd++splbz++ddaso+dln-dstsqlm
d+-sr[PPPP]ss[IP]su[lpdlqlrlsxlu
x]lm:f[lpdltdI+lm+rlblm+-lsxlux]
ln:f[[]sulm;fxln;f[IP]sux]la:f[;
fsk]sg[lmlgx]sh[lnlgx]si[lalgx]s
j[lc[lcp]sklerldlolclerlblolcler
lalox=hx=ix=jlkxclcz+scllx]dslx
share|improve this answer
    
+1 for dc. Even unobfuscated, of course, it's not especially readable. –  Jesse Millikan Mar 14 '11 at 21:29
    
Love the Avatar! –  Malachi Jul 18 at 13:20

Haskell - 147 142 138 characters

fi=zz.bu
bu=zz.(:).(++"zz")
[]#zz=zz;zz#__=zz
zZ%zz=zZ zz$zZ%zz
zz=(([[],[]]++).)
z=zipWith3(((#).).(++))(bu%"Fi")(fi%"Bu")$map show[1..]

The code is 19 characters longer than it needs to be, but I thought the aesthetics were worth it! I believe all three "objectives" are satisfied.

> take 20 z
["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14",
"FizzBuzz","16","17","Fizz","19","Buzz"]
share|improve this answer
    
Hi, I try to get to understand your code, but I am unable to run it! The function zZ' is applied to six arguments, but its type (a0 -> b0 -> c0) -> [a0] -> [b0] -> [c0]' has only three –  RobAu Jan 31 '13 at 20:07
    
And I, while being able to run it, only get ["1","2","3","4","5","6"...]. –  Artyom Kazak Feb 1 '13 at 18:14
    
Fixed - The right version was still on my disk... must have mis-pasted the text long ago! –  MtnViewMark Feb 5 '13 at 4:52
    
please specify how can it be shortened by 19 characters, or show the code. i am curious and i have no idea –  proud haskeller Jul 18 at 15:31
    
There are 19 occurrances of 2 letter names: bu, fi, zz, and zZ. These could be shortened to one letter names. –  MtnViewMark Jul 19 at 1:17

Brainfuck - 626 656

+[[>+>+<<-]>>>+++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]<[<+>>+<-]>>[-]+++>[
<<<+>>>-]>[-]<<<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[-]<<<<[>+<-]>>>[<
<<+>>>-]<<[>>+<<-]<[>+>+<<-]>[<+>-]+>[<->[-]]<[>>>[-]>[-]<>+++++++[<++
++++++++>-]<.>+++++[<+++++++>-]<.+++++++++++++++++..[-]+<<<-]<[-]>>>[<
+<+>>-]<[>+<-]+<[>-<[-]]>[>>>[-]>[-]<>++++++[<+++++++++++>-]<.>+++++[<
++++++++++>-]<+.+++++..[-]<+<<-]>[-]>[<+<+>>-]<[>+<-]+<[>-<[-]]>[<<<<[
>+>>>>+<<<<<-]>[<+>-]>>>>>>--[<->+++++]<--<[->-[>+>>]>[+[-<+>]>+>>]<<<
<<]>[-]<-[>-<+++++]>--->>[<<[<+>>>+<<-]<[>+<-]>>>.[-]]++++++++++<[->-[
>+>>]>[+[-<+>]>+>>]<<<<<]>[-]<<[>+>>>+<<<<-]>>>>.[-]<<<[>>+<<-]>>.[-]<
<<<<-]<<<++++++++++.[-]<+]

Goes from 1 to 255

share|improve this answer
    
Turns out this actually does BuzzFizz. It gets FizzBuzz correct for %15, but it swaps %3 and %5. I may try to fix it, but for now my brain is officially F'ed –  CMP Dec 15 '11 at 23:32
2  
Fixed at cost of 30. Could have golfed it more with effort, but I have already wasted enough time on this. –  CMP Dec 15 '11 at 23:36
    
"waste" is a strong word ... –  Claudiu Aug 22 at 23:00

Scala, 295 characters

object F extends Application{var(f,i,z)=("",('z'/'z'),"FBiuzzzz");while(i<(-'b'+'u'+'z'/'z')*('¥'/'!')){if(i%(-'f'+'i'/('z'/'z'))==0)f+=z.sliding(1,2).mkString;if(i%((-'b'+'u'+'z'/'z')/('f'/'f'+'i'/'i'+'z'/'z'+'z'/'z'))==0)f+=z.drop(1).sliding(1,2).mkString;if(f=="")f+=i;println(f);i+=1;f="";}}
share|improve this answer

Ruby - 165 characters

(1..100).each{|i|i%0xF==0? puts(["46697A7A42757A7A"].pack("H*")):i%(0xD-0xA)==0? puts(["46697A7A"].pack("H*")):i%(0xF-0xA)==0? puts(["42757A7A"].pack("H*")):puts(i)}

This was my first attempt at code golf. I had a lot of fun. =)

share|improve this answer

Brainfuck, 708 characters

++++++++++[>++++++++++<-]>>++++++++++>->>>>>>>>>>>>>>>>-->+++++++[->++
++++++++<]>[->+>+>+>+<<<<]+++>>+++>>>++++++++[-<++++<++++<++++>>>]++++
+[-<++++<++++>>]>>-->++++++[->+++++++++++<]>[->+>+>+>+<<<<]+++++>>+>++
++++>++++++>++++++++[-<++++<++++<++++>>>]++++++[-<+++<+++<+++>>>]>>-->
---+[-<+]-<[+[->+]-<<->>>+>[-]++[-->++]-->+++[---++[--<++]---->>-<+>[+
+++[----<++++]--[>]++[-->++]--<]>++[--+[-<+]->>[-]+++++[---->++++]-->[
->+<]>>[.>]++[-->++]]-->+++]---+[-<+]->>-[+>>>+[-<+]->>>++++++++++<<[-
>+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>
+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->+++
+++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]+[-<+]->>]+[-]<<<.>>>+[
-<+]-<<]

Description of how it works is available in my Code Review question

share|improve this answer

JavaScript 111 chars - no key numbers

a=b=c=0;while(a++<99)document.write((b>1?(b=0,"Fizz"):(b++,""))+(c==4?(c=0,"Buzz"):(c++,""))+(b*c?a:"")+"<br>")

share|improve this answer

C# - 218 characters

using System;class D{static void Main(){int l,i,O=1;l++;string c="zz",a="fi",b="bu";l++;l++;i=l;i++;i++;for(;O<101;O++)Console.WriteLine(((O%l)>0&&1>(O%i))?a+c:(1>(O%l)&&(O%i)>0)?b+c:(1>(O%l)&&1>(O%i))?a+c+b+c:O+"");}}

Could be shortened if I introduced other numbers like so: (210 characters total)

using System;class D{static void Main(){int l=1,i,O=1;string c="zz",a="fi",b="bu";l+=2;i=l;i+=2;for(;O<101;O++)Console.WriteLine(((O%l)>0&&1>(O%i))?a+c:(1>(O%l)&&(O%i)>0)?b+c:(1>(O%l)&&1>(O%i))?a+c+b+c:O+"");}}

Decided to remove the obvious word fizz and buzz and go for slightly more obfuscation. Second one is shorter than the first one but is slightly more direct on what's occurring in the addition.

share|improve this answer

C (237 209 characters)

#include<stdlib.h>
#define e printf  
a=50358598,b=83916098,c=1862302330;_(m,n){return(m%((c&n)>>24))
||!(e(&n)|e(&c));}main(_);(*__[])(_)={main,exit};main(i){_(i,a)
&_(i,b)&&e("%i",i);e("\n");__[i>=100](++i);}

Though I'm not sure this conforms to the C standard :)
It works, though. On Linux using GCC, that is.

share|improve this answer

Python 3 - 338

import sys
def fibu():
        (F,I,B,U),i,u,z=sys._getframe(0).f_code.co_name,0xf,0xb,lambda x,y:x%((i//u)+(i^u))==u>>i if y>u else x%(((u<<(u>>2))&i)>>(u>>2))==i>>u
        A,RP = "",chr(ord(U)+((i//u)+(i^u)))*2
        for x in range(100):print(x if not (z(x,u)or z(x,i))else A.join((F+I+RP if z(x,u)else A,B+U+RP if z(x,i)else A)))
fibu()

This is my first golf. Not the shortest, but it's pretty ugly! None of the forbidden numbers or string literals. Firp, Burp!

share|improve this answer

Python - 157

from itertools import cycle as r
c=str.replace
[c(c(c(z+y,'x','fix'),'y','bux'),'x','zz').strip() or x for z,y,x in zip(r('  y'),r('    x'),range(1,101))]

Not quite the shortest, but I hope the reader will appreciate the pure functional style and extensibility to arbitrarily long counts.

share|improve this answer

K, 155

{m:{x-y*x div y};s:{"c"$(10-!#x)+"i"$x};$[&/0=m[x]'(2+"I"$"c"$49;4+"I"$"c"$49);s"<`rs<pvw";0=m[x;2+"I"$"c"$49];s"<`rs";0=m[x;4+"I"$"c"$49];s"8lrs";x]}'!100

I could golf it quite a bit but I'd rather it be more obfuscated.

share|improve this answer

This isn't exactly golfed, its about 120 lines.

I thought I'd do something that took advantage of all the fun potential for undefined behavior with C++ memory management.

#include <iostream>
#include <string>

using namespace std;

class Weh;
class HelloWorld;

class Weh
{
public:

    string value1;
    string value2;
    void (*method)(void * obj);

    Weh();

    string getV1();

    static void doNothing(void * obj);
};

class HelloWorld
{
public:
    static const int FOO = 1;
    static const int BAR = 2;
    static const int BAZ = 4;
    static const int WUG = 8;

    string hello;
    string world;
    void (*doHello)(HelloWorld * obj);

    HelloWorld();

    void * operator new(size_t size);

    void tower(int i);
    const char * doTower(int i, int j, int k);

    static void doHe1lo(HelloWorld * obj);
};

Weh::Weh()
{
    method = &doNothing;
}

void Weh::doNothing(void * obj)
{
    string s = ((Weh *) obj)->getV1();
    ((HelloWorld *) obj)->tower(1);
}

string Weh::getV1()
{
    value1[0] += 'h' - 'j' - 32;
    value1[1] += 'k' - 'g';
    value1[2] += 'u' - 'g';
    value1[3] = value1[2];
    value2 = value1 = value1.substr(0, 4);

    value2[0] += 'd' - 'h';
    value2[1] += 'w' - 'k';
    value2[2] = value1[2];
    value2[3] = value1[3];

    return "hello";
}

void * HelloWorld::operator new(size_t size)
{
    return (void *) new Weh;
}

HelloWorld::HelloWorld()
{
    hello = "hello";
    world = "world";
}

void HelloWorld::doHe1lo(HelloWorld * obj)
{
    cout << obj->hello << " " << obj->world << "!" << endl;
}

void HelloWorld::tower(int i)
{
    doTower(0, 0, i);
    tower(i + (FOO | BAR | BAZ | WUG));
}

const char * HelloWorld::doTower(int i, int j, int k)
{
    static const char * NOTHING = "";
    int hello = BAR;
    int world = BAZ;
    int helloworld = FOO | BAR | BAZ | WUG;

    if ((hello & i) && (world & j))
        cout << this->hello << this->world << endl;
    else if (hello & i)
    {
        cout << this->hello << endl;
        cout << doTower(0, j + 1, k + 1);
    }
    else if (world & j)
    {
        cout << this->world << endl;
        cout << doTower(i + 1, 0, k + 1);
    }
    else
    {
        cout << k << endl;
        cout << doTower(i + 1, j + 1, k + 1);
    }

    return NOTHING;
}

int main()
{
    HelloWorld * h = new HelloWorld;
    h->doHello(h);
}
share|improve this answer

Ruby - 89 chars

puts (0..99).map{|i|srand(1781773465)if(i%15==0);[i+1,"Fizz","Buzz","FizzBuzz"][rand(4)]}

I can't take credit for this piece of brilliance, but I couldn't leave this question without my favorite obfuscated implementation :)

The implementation above was written by David Brady and is from the fizzbuzz ruby gem. Here is the explanation from the source code:

Uses the fact that seed 1781773465 in Ruby's rand will generate the 15-digit sequence that repeats in the FizzBuzz progression. The premise here is that we want to cleverly trick rand into delivering a predictable sequence. (It is interesting to note that we don't actually gain a reduction in information size. The 15-digit sequence can be encoded as bit pairs and stored in a 30-bit number. Since 1781773465 requires 31 bits of storage, our cleverness has actually cost us a bit of storage efficiency. BUT THAT'S NOT THE POINT!

Ruby - 87 chars

puts (0..99).map{|i|srand(46308667)if(i%15==0);["FizzBuzz","Buzz",i+1,"Fizz"][rand(4)]}

Here's a different version which uses a shorter seed but the lookup table is in a different order. Here is the explanation from the source code:

The first implementation (89 chars) adheres to the specific ordering of 0=int, 1=Fizz, 2=Buzz, 3=FizzBuzz. It may be possible to find a smaller key if the ordering is changed. There are 24 possible permutations. If we assume that the permutations are evenly distributed throughout 2*31 space, and about a 50% probability that this one is "about halfway through", then we can assume with a decent confidence (say 20-50%) that there is a key somewhere around 1.4e+9 (below 2*28). It's not much gain but it DOES demonstrate leveraging rand's predefined sequence to "hide" 30 bits of information in less that 30 bits of space.

Result: The permutation [3,2,0,1] appears at seed 46308667, which can be stored in 26 bits.

share|improve this answer
2  
very sweet, but does contain a literal "Fizz", "Buzz" etc so not valid according to the rules –  Arne Brasseur Jun 28 at 20:05

Squeak (4.4) Smalltalk 206 bytes

|f i zz b u z|z:=''.b:=28r1J8D0LK. 1to:100do:[:o|0<(f:=(i:=(zz:=b\\4)//2*4)+(u:=zz\\2*4))or:[z:=z,o].b:=zz<<28+(b//4).z:=z,((z first:f)replaceFrom:1to:f with:28r1A041FHQIC7EJI>>(4-i*u*2)startingAt:1),'
'].z

Or same algorithm with less explicit messages, same number of characters

|l f i zz b u z|z:=#[].b:=36rDEB30W. 1to:100do:[:o|0<(f:=(i:=(zz:=b\\4)//2)+(u:=zz\\2)*4)or:[z:=z,('',o)].b:=zz<<28+(b//4).l:=36r2JUQE92ONA>>(1-u*i*24).1to:f do:[:k|z:=z,{l-((l:=l>>6)-1<<6)}].z:=z,'
'].'',z

My apologizes to Alan Kay for what I did to Smalltalk.
Some of these hacks are portable across Smalltalk dialects, some would require a Squeak compatibility layer...

Note that if you execute in a Workspace, you can omit declarations |f i zz b u z| and gain 14 characters.

If we can afford 357 characters (315 with single letter vars), then it's better to avoid trivial #to:do: loop:

|fizz buzz if f fi zz b u bu z|f:=fizz:=buzz:=0.z:=#[].b:=814090528.if:=[:i|i=0or:[fi:=28.zz:=27<<7+i.u:=26.(fizz:=[zz=0or:[z:=z,{(u:=u//2)\\2+1+(zz+((fi:=fi//2)\\2+2-(zz:=zz//8)*8)*4)}.fizz value]])value]].(buzz:=[(f:=f+1)>100or:[(fi:=(zz:=b\\4)//2*17)+(bu:=zz\\2*40)>0or:[z:=z,('',f)].b:=zz<<28+(b//4).if value:fi;value:bu.z:=z,'
'.buzz value]])value.'',z
share|improve this answer

Perl 6 (52 bytes)

say "Fizz"x$_%%(2+1)~"Buzz"x$_%%(4+1)||$_ for 1..100

Let me put an explanation here. It's the worst rule abuse I've done in such task. I know what you are saying - there is obvious Fizz and Buzz here. But let's take a look at the rules.

To be considered obfuscated, it should satisfy at least one of the following:

This avoids 3, 5 and 15. Therefore, it's valid and really short solution.

share|improve this answer

Python, 1 line, 376 characters

pep8-E501 ignored. Only works in python3.

print(*((lambda x=x: ''.join(chr(c) for c in (102, 105)) + (2 * chr(122)) + ''.join(chr(c) for c in (98, 117)) + (2 * chr(122)) + '\n' if x % (30 >> 1) == 0 else ''.join(chr(c) for c in (102, 105)) + (2 * chr(122)) + '\n' if x % (6 >> 1) == 0 else ''.join(chr(c) for c in (98, 117)) + (2 * chr(122)) + '\n' if x % (10 >> 1) == 0 else str(x) + '\n')() for x in range(1, 101)))
share|improve this answer

Perl

use MIME::Base64;print map{map{(++$i,'Fizz','Buzz','FizzBuzz')[$_]."\n"}(3&ord,3&ord>>2,3&ord>>4,3&ord>>6)}split//,decode_base64"EAZJMIRBEgxhkARDGCTBEAZJMIRBEgxhkA"

One I made in 2009. It's pretty easy to figure out, though.

Edit: Darn, it uses "Fizz" and "Buzz!" :( I thought I changed that. Nevermind then.

share|improve this answer

C 216 bytes

#define t(b) putchar(p+=b);
main(p,v,c){p=70;for(v=c=1;v<=p*2-40&&!(c=0);++v){if(!(v%(p/23))){t(0)t(35)t(17)t(0)++c;}if(!(v%(p/(14+c*9)))){t(-56+!c*52)t(51)t(5)t(0);++c;}if(c){t(-112)p+=60;}else printf("%i\n",v);}}
share|improve this answer

PHP - 157 154 95 chars

<?$x="zz";for(;++$i<=100;){?> <?$j=$i%(4-1)^0?"":"Fi$x";$j.=$i%(4+1)^0?"":"Bu$x";echo$j?$j:$i;}

And no whitespace! Only one space!

share|improve this answer

Haskell 226 bytes, including the whitespace for layout ;)

z=[fI$ (++)            \ 
(fi zz 1 "Fi" )        \  
(fi zz 2 "Bu" )        \ 
:[show zz]  | zz<-[1..]]
fI (zZ:zz)  | zZ==[]   \
= concat zz | 1==1=zZ  
fi zZ bu zz | zZ%bu=   \
(zz++"zz")  | 1==1=[] 
bu%zz=mod bu (zz*2+1)==0

The 'real' code is 160 bytes and can be compressed, but loses fizz-buzz-ness then.

Run it (for nice output):

putStrLn (unwords (take 20 z ))

Output:

1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz 
share|improve this answer

Python, 180 chars

from random import*;seed(0);_,y=''.join(sample('zzzzuiFB',8)),5**2<<2
print chr(int(`y`[::2])).join(filter(bool,map(lambda z:(not z%(y>>5))*_[:1<<2:]+(1>z%5)*_[1<<2::],range(1,y))))
share|improve this answer

Here's a fun one in C. It can be shorter, but then it won't be as much fun!

#define i(bu,zz,fi) printf("?"[1]|""[0]?"fi":"%"#zz"\n",bu)
#define x(a,i,p) {-0xf##i&(3+5-1),{z(z,a,p,),""}}
#define z(b,f,z,l) #z#f""#b""#l#b
main(b){struct{char z;char*u[2];}u[]={x(i,d,f),x(u,b,b),{0}};for(b=1;b<'e';b++)
{int z=0;char f[3+5+1]={0};for(b;u[z].z;z++)strcat(f,u[z].u[!!(b%u[z].z)]);*f&&
i(f,s,3)||i(b,d,5);}}
share|improve this answer

Alternative Ruby (126 characters)

(1..100).map{|i|(x="\xF\3\5\1Rml6ekJ1eno=".unpack('C4m'))[-1]=~/(.*)(B.*)/
[*$~,i].zip(x).map{|o,d|i%d>0||(break $><<o<<?\n)}}

Short and obscure, just how we like it. The 3 and the 5 are actually in there but not as integer literals so I think that still counts.

Note that the this is the shortest Ruby version without literal 'Fizz', 'Buzz', 'FizzBuzz' on here.

share|improve this answer

This was a bit tricky to embed using the indentation so a gist:

Ruby, 4312 chars

https://gist.github.com/dzucconi/1f88a6dffa2f145f370f

eval("                                                 

















































                                                                                                                             ".split(/\n/).map(&:size).pack("C*"))
share|improve this answer
    
I added the code anyway, then people immediately see how it is obfuscated. Instead of a gist, I would also link to your code on ideone.com (an online code running environment), so people can immediately test it there without having copy/paste problems. –  ProgramFOX Jul 25 at 14:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.