Skip to main content
Commonmark migration
Source Link

###Explanation:

Explanation:

###Explanation:

Explanation:

-8 bytes
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Brain-Flak, 474 470 446 438 420 420412 bytes

-8 thanks to Wheat Wizard

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

Try it online!Try it online!

(((()()()()()){}){}) Push 20
{ Loop 20 times
    ({}
    <[(()())> ]    Push a 2 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 2 to the last one
}<>{}{} Pop the excess two elements

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

{ Loop over each element
    ([{}]()) Subtract one from the current element
    ({ Fizz and/or Buzz if num is not 1
        <(({}())())  Subtract 1 and push, twice
        { Push Buzz if num was not 3
            (<{}>)(((((((()()()())())((((({}(){}){})[()]){}){}())(()()){}())){({}<>)<>}
        }{}
        { Push Fizz if num is not 2
            (<{}>)(((((()()()())({})){}())(({})({}())({}{})))){({}<>)<>}
        }
        >
        ()
    }{}[()]) Push -1 if it'sneither aFizz numbernor Buzz were pushed
    {
        ([](<>)) Push length of list to other stack
        <>((()()()()()){}) Push 10 as the mod
        Div/mod algorithm
        {(({}<({}())>)){({}[()])<>}{}}{}<>([{}()]{}<>)<>
        Pushes n%10 to output stack and n/10 to the list stack
        { If div is not 0
            ({}<>) Push it to the other stack
            (<>)   Push 0
        }
    }{} Pop excess 0
    (<>)<> Push 0 to other stack to represent a newline
}<>{} Pop extra newline
{ Loop over values
    {
        ({}((((()()()){}){}){}){}<>)<>  Add 48 to every value
    }
    ({}(()()()()()){}<>)<> Turn 0s into newlines
}  Until there's two 0s in a row
<>{({}<>)<>}<> Reverse output

Brain-Flak, 474 470 446 438 420 bytes

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

Try it online!

(((()()()()()){}){}) Push 20
{ Loop 20 times
    ({}
    <(()())>     Push a 2 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 2 to the last one
}<>{}{} Pop the excess two elements

Now 1 represents normal numbers, 2 represents Buzz, 3 is Fizz and 4 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 and push twice
        { Push Buzz
            (<{}>)((((((((()()()()){}()){})[()]){}){}())(()()){}())){({}<>)<>}
        }{}
        { Push Fizz
            (<{}>)(((((()()()())({})){}())(({})({}())({}{})))){({}<>)<>}
        }
        >
        ()
    }{}[()]) Push -1 if it's a number
    {
        ([](<>)) Push length of list to other stack
        <>((()()()()()){}) Push 10 as the mod
        Div/mod algorithm
        {(({}<({}())>)){({}[()])<>}{}}{}<>([{}()]{}<>)<>
        Pushes n%10 to output stack and n/10 to the list stack
        { If div is not 0
            ({}<>) Push it to the other stack
            (<>)   Push 0
        }
    }{} Pop excess 0
    (<>)<> Push 0 to other stack to represent a newline
}<>{} Pop extra newline
{ Loop over values
    {
        ({}((((()()()){}){}){}){}<>)<>  Add 48 to every value
    }
    ({}(()()()()()){}<>)<> Turn 0s into newlines
}  Until there's two 0s in a row
<>{({}<>)<>}<> Reverse output

Brain-Flak, 474 470 446 438 420 412 bytes

-8 thanks to Wheat Wizard

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

Try it online!

(((()()()()()){}){}) Push 20
{ Loop 20 times
    ({}
    [(()())]    Push a 2 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 2 to the last one
}<>{}{} Pop the excess two elements

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

{ Loop over each element
    ([{}]()) Subtract one from the current element
    ({ Fizz and/or Buzz if num is not 1
        <(({}())())  Subtract 1 and push, twice
        { Push Buzz if num was not 3
            (<{}>)((((()()()())())((((({}{}){})[()]){}){}()))){({}<>)<>}
        }{}
        { Push Fizz if num is not 2
            (<{}>)(((((()()()())({})){}())(({})({}())({}{})))){({}<>)<>}
        }
        >
        ()
    }{}[()]) Push -1 if neither Fizz nor Buzz were pushed
    {
        ([](<>)) Push length of list to other stack
        <>((()()()()()){}) Push 10 as the mod
        Div/mod algorithm
        {(({}<({}())>)){({}[()])<>}{}}{}<>([{}()]{}<>)<>
        Pushes n%10 to output stack and n/10 to the list stack
        { If div is not 0
            ({}<>) Push it to the other stack
            (<>)   Push 0
        }
    }{} Pop excess 0
    (<>)<> Push 0 to other stack to represent a newline
}<>{} Pop extra newline
{ Loop over values
    {
        ({}((((()()()){}){}){}){}<>)<>  Add 48 to every value
    }
    ({}(()()()()()){}<>)<> Turn 0s into newlines
}  Until there's two 0s in a row
<>{({}<>)<>}<> Reverse output
edited body
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

-2818 bytes thanks to Nitroden!

-28 bytes thanks to Nitroden!

-18 bytes thanks to Nitroden!

added 3 characters in body
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading
-8 bytes
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading
added 15 characters in body
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading
-24 bytes
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading
-4 bytes
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading
fixed typo
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Loading