Skip to main content

Fizz Buzz Boing Bang Challenge

Rafal Wolsztyniak

FizzBuzzBoingBang

Participation Award > Nothing

In September I took part in the FizzBuzzBoingBang coding challenge organized by Cameron Roberts on his blog.

Well, I didn't do as well as I thought, but I still was able to get a honourable mention (be sure to head there to see a nice trick with the IIF() function that could be useful in next challenges utilizing AMPscript).

I thought that adding two extra divisors to the normal Fizz Buzz game would make the nesting IIFs a less viable choice, but I was wrong as proven by the amazing solutions provided by the winners.

Hope to see more challenges like this as it's an excellent way of training coding in creative ways.

My solution

For reference, here's how my code looked like (with some slight formatting for readability made by Cameron):

%%[SET @r=BuildRowsetFromString('3♫5♫7♫11♫Fizz♫Buzz♫Boing♫Bang','♫')
FOR @x=1 to 1000 DO
SET @l=@x
FOR @y=1 to 4 DO
SET @l=Concat(@l,IIF(Mod(@x,Field(Row(@r,@y),1))==0,Field(Row(@r,Add(4,@y)),1),''))
NEXT @y]%%
%%=v(IIF(@l==@x,@l,Replace(@l,@x,'')))=%%<br>
%%[NEXT]%%

This can now be treated as an attempt to prepare a more scalable solution that could work with slight alterations if new divisors and their corresponding words would be added.