Build a "BizzFuzz" program
Python, 114
a='Fizz'
b='Buzz'
c='Bizz'
d='Fuzz'
e=c+d
f=a+b
g=b+a
i=1
exec"print eval('ediifiiiaibiaiigiiic'[i%20]);i+=1;"*100
Original solution (131):
f='Fizz'
for i in range(1,101):x=i%20;print('Bizz'*(x%19<1)+'Fuzz'*(x<2)or(i%4<1)*f+'Buzz'*(i%5<1or x==4)+f*(x==15)or i,i)[x%11==5]
GolfScript (83 80 chars)
(NB Howard's suggestion in the comments allows to reduce to 78 chars, but with trailing spaces on some lines).
This uses the character \0
, so here it is in xxd format:
0000000: 3130 302c 7b29 2e32 3025 2742 6946 750a 100,{).20%'BiFu.
0000010: 0046 750a 0000 0046 6942 750a 0000 0000 .Fu....FiBu.....
0000020: 4669 0a00 0042 750a 0000 4669 0a00 0000 Fi...Bu...Fi....
0000030: 4275 4669 0a00 0000 0042 690a 2731 2c2f BuFi.....Bi.'1,/
0000040: 3d32 2f27 7a7a 272a 5c6e 2b6f 727d 2f0a =2/'zz'*\n+or}/.
and base64:
MTAwLHspLjIwJSdCaUZ1CgBGdQoAAABGaUJ1CgAAAABGaQoAAEJ1CgAARmkKAAAAQnVGaQoAAAAA
QmkKJzEsLz0yLyd6eicqXG4rb3J9Lwo=
Using ^ as a stand-in for \0
, it's
100,{).20%'BiFu ^Fu ^^^FiBu ^^^^Fi ^^Bu ^^Fi ^^^BuFi ^^^^Bi '1,/=2/'zz'*\n+or}/
Still not a particularly interesting problem.
An explanation was requested:
For values 0
to 99
inclusive:
100,{
...
}/
Increment the value (we want 1
to 100
) and also find out what the incremented value is mod 20
:
).20%
Split the magic string around \0
characters:
MAGIC_STRING 1,/
Take the (x mod 20
)th element of that array, split it into 2-character chunks, and glue them back together with zz
. Note: the string is either empty (in which case there are no chunks, so we end up with the empty string) or is a sequence of [BF][iu]
prefixes followed by a newline.
=2/'zz'*
Take the other copy of the incremented number which we kept on the stack, and append a newline. Now whichever string we keep will end with a newline.
\n+
Apply a fallback operation. (This is similar to ||
in JavaScript or COALESCE
in SQL).
or
Python 2, 131
F,B,Z,I='Fizz','Buzz','Fuzz','Bizz'
for i in range(1,101):print{5:Z,19:I,i%4:B,i%5*4:F,3:B+F,16:F+B,0:I+Z,1:i,4:i}.get(i%4+i%5*4,i)