Skip to main content
3 of 10
-4 bytes
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Brain-Flak, 474 470 bytes

(((()()()()()){}){}){({}<(()()())>[((((()))))])}{}{({}<>)<>({}<>)<>({}()<>)<>}<>{}{}{([({}[()])]{(({}[()]))<{(<{}>)(((((((((()()()()){}){}){}()){})[(()()()()){}]){}())(()()){}())){({}<>)<>}}{}({}[()]){{}<>(((((((((()()()){}()){}()){}){}()){}))[((()()()()){}){}()])[(((()()()()){}){}()){}()])(<>)}>}{}()){({}[](<>))(<>[()])((()()()()()){}){(({}<({}())>)){({}[()])<>}{}}{}<>([{}()]{}((((()()()){}){}){}){}<>)<>{({}((((()()()){}){}){}){}<>)(<>)}}{}<>((()()()()()){})<>}<>{}

Try it online!

Gosh, it's nice to finally check this off my to-do list.

###Explanation:

Brain-Flak is obviously not very good at getting the modulo of numbers, so I bypassed this by pushing all the elements first.

(((()()()()()){}){}) Push 20
{ Loop 20 times
    ({}
    <(()()())>    Push a 3 to represent a Buzz
    [((((()))))] Push 4 1s
    ) And decrement loop counter
}{} Pop the excess 0
{ Loop over the list of numbers
    ({}<>)<>({}<>)<> Transfer two of the elements to the other stack
    ({}()<>)<>       And add one to the last one
}<>{}{} Pop the excess two elements

Now 1 represents normal numbers, 2 representa Buzz, 3s represents FizzBuzz. Initially I just pushed the values that repeat every 15 numbers 7 times and popped the excess 5, but this way turned to be slightly shorter.

{ Loop over each element
    ([({}[()])] Subtract one from the current element
    { Fizz and/or Buzz
        (({}[()])) Subtract 1 again
        <
        { Push Buzz
            (<{}>)(((((((((()()()()){}){}){}()){})[(()()()()){}]){}())(()()){}())){({}<>)<>}
        }{}
        ({}[()]) Subtract 1 again
        { Push Fizz
            {}<>(((((((((()()()){}()){}()){}){}()){}))[((()()()()){}){}()])[(((()()()()){}){}()){}()])(<>)
        }
        >
    }{}()) Push 1 if it's a number
    {
        ({}[](<>)) Push length of list to other stack
        (<>[()])((()()()()()){}) Push -1 and 10
        Div/mod algorithm
        {(({}<({}())>)){({}[()])<>}{}}{}<>([{}()]{}((((()()()){}){}){}){}<>)<>
        Pushes n%10+48 to output stack and n/10 to the list stack
        { If div is not 0
            ({}((((()()()){}){}){}){}<>) Add 48 to it and push it to other stack
            (<>) Push 0
        }
    }{} Pop excess 0
    <>((()()()()()){})<> Push newline to other stack
}<>{} Pop extra newline

Jo King
  • 47.5k
  • 5
  • 125
  • 186