Advertisement
leomaster

FizzBuzz

Mar 15th, 2018 (edited)
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Write a program that prints the numbers from 1 to 100.
  2. But for multiples of three print “Fizz” instead of the
  3. number and for the multiples of five print “Buzz”. For
  4. numbers which are multiples of both three and five
  5. print “FizzBuzz” */
  6.  
  7. Object.values([...Array(1e2).keys()].map(key=>['Fi','Bu'].reduce((acc,itr,idx)=>acc+((-~key%(idx*2+3))?'':`${itr}zz`),'')||-~key)).join('\n')
  8.  
  9. [...Array(1e2)].reduce((s,l,k)=>s+(['Fi','Bu'].reduce((a,e,i)=>a+(-~k%-~(-~i<<-~{})?'':`${e}zz`),'')||-~k)+'\n','\n')
  10.  
  11. (λ=>[...Array(1e2)].reduce((s,e,i)=>(s+((λ[-~-!(-~i%3)]+λ[-~!(-~i%5)])||-~i))+'\n',''))(['Fizz','','Buzz'])
  12.  
  13. (λ=ǃ=>+!~-ǃ||λ(~-ǃ)+'\n'+((ǃ%3?'':'Fizz')+(ǃ%5?'':'Buzz')||ǃ))(100)
  14.  
  15. (λ=ǃ=>+!~-ǃ||λ(~-ǃ)+'\n'+(['Fizz',''][ǃ%3&&1]+['Buzz',''][ǃ%5&&1]||ǃ))(100)
  16.  
  17. (λ=n=>+!~-n||`${λ(~-n)}
  18. ${(`${n%3?'':'Fizz'}${n%5?'':'Buzz'}`||n)}`)(1e2)
  19.  
  20. (λ=n=>+!~-n||λ(~-n)+'\n'+(['','Fizz'][+!(n%3)]+['','Buzz'][+!(n%5)]||n))(1e2)
  21.  
  22. (λ=n=>+!~-n||λ(~-n)+'\n'+(['Fizz','',''][n%3]+['Buzz','','','',''][n%5]||n))(1e2)
  23.  
  24. (λ=(ǃ,$=+!'')=>+!~-ǃ||λ(~-ǃ)+'\n'+((φ=>φ`Fizz`+φ`Buzz`)(Σ=>['',Σ][+!(ǃ%(-~((-~(++$&-~''))<<-~'')))])||ǃ))(1e2)
  25.  
  26. [...Array(100).keys()].map(n=>['FizzBuzz',n,,,,,'Buzz',,,,'Fizz'][n**4%15])
  27.  
  28. console.log((λ=ǃ=>+!~-ǃ||λ(~-ǃ)+'\n'+(['FizzBuzz',ǃ,,,,,'Buzz',,,,'Fizz'])[ǃ**4%15])(1e2));
  29.  
  30. for (n=1;n<=100;++n) console.log(['FizzBuzz',n,,,,,'Buzz',,,,'Fizz'][n**4%15] + '\n');
  31.  
  32. for (n=1;n<=100;++n) console.log(({0:'FizzBuzz',1:n,6:'Fizz',10:'Buzz'})[n**4%15] + '\n');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement