Skip to main content
added a reference to the twin challenge
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 82 bytes

Saved 2 bytes thanks to a suggestion by @emanresuA

Expects and returns -1 for Fizz, -2 for Buzz, -3 for FizzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>-!(++i%3)-2*!(i%5)||i)].sort()+''==a?b:f(a,++k) 

Try it online!

The underlying algorithm is the same as in my answer to the twin challenge.

JavaScript (ES6), 82 bytes

Saved 2 bytes thanks to a suggestion by @emanresuA

Expects and returns -1 for Fizz, -2 for Buzz, -3 for FizzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>-!(++i%3)-2*!(i%5)||i)].sort()+''==a?b:f(a,++k) 

Try it online!

JavaScript (ES6), 82 bytes

Saved 2 bytes thanks to a suggestion by @emanresuA

Expects and returns -1 for Fizz, -2 for Buzz, -3 for FizzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>-!(++i%3)-2*!(i%5)||i)].sort()+''==a?b:f(a,++k) 

Try it online!

The underlying algorithm is the same as in my answer to the twin challenge.

saved 2 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 8482 bytes

Saved 2 bytes thanks to a suggestion by @emanresuA

Expects and returns -1 for FizzBuzzFizz, -2 for FizzBuzz, -3 for BuzzFizzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>++i%3?i%5?i:_=>-3:!(++i%3)-2^i%5<12*!(i%5)||i)].sort()+''==a?b:f(a,++k) 

Try it online!Try it online!

JavaScript (ES6), 84 bytes

Expects and returns -1 for FizzBuzz, -2 for Fizz, -3 for Buzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>++i%3?i%5?i:-3:-2^i%5<1)].sort()+''==a?b:f(a,++k) 

Try it online!

JavaScript (ES6), 82 bytes

Saved 2 bytes thanks to a suggestion by @emanresuA

Expects and returns -1 for Fizz, -2 for Buzz, -3 for FizzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>-!(++i%3)-2*!(i%5)||i)].sort()+''==a?b:f(a,++k) 

Try it online!

saved 1 byte
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 8584 bytes

Expects and returns -1 for FizzFizzBuzz, -2 for BuzzFizz, -3 for FizzBuzzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>++i%3?i%5?i:-2:i%5?-13:-32^i%5<1)].sort()+''==a?b:f(a,++k) 

Try it online!Try it online!

JavaScript (ES6), 85 bytes

Expects and returns -1 for Fizz, -2 for Buzz, -3 for FizzBuzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>++i%3?i%5?i:-2:i%5?-1:-3)].sort()+''==a?b:f(a,++k) 

Try it online!

JavaScript (ES6), 84 bytes

Expects and returns -1 for FizzBuzz, -2 for Fizz, -3 for Buzz.

f=(a,i=k=0)=>[...b=a.sort().map(_=>++i%3?i%5?i:-3:-2^i%5<1)].sort()+''==a?b:f(a,++k) 

Try it online!

saved 2 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading