Skip to content

Instantly share code, notes, and snippets.

@kevincharm
Last active November 29, 2017 03:57
Show Gist options
  • Save kevincharm/ddd5f0e954063cd81f7a40e9e361178e to your computer and use it in GitHub Desktop.
Save kevincharm/ddd5f0e954063cd81f7a40e9e361178e to your computer and use it in GitHub Desktop.
The Fizziest of Buzzes. Note: this is a joke.
const magic = 0x46697a7a
const witchcraft = magic ^ (0x41c << 16)
const u = x => a => b => (x >> a) + (x & b)
const v = x => a => b => x > a ? x - b : x
const w = x => u(u(u(x)(16)(0xffff))(8)(0xff))(4)(0xf)
const rin = x => s => !!parseInt(x) ? s : x + s
const c = x => a => b => String.fromCharCode((x >> a) & b)
const cccc = x => c(x)(24)(0xff)+c(x)(16)(0xff)+c(x)(8)(0xff)+c(x)(0)(0xff)
const fizz = x => !(v(u(u(u(w(x))(2)(3))(2)(3))(2)(3))(2)(3))
const buzz = x => !(v(v(v(w(x))(14)(15))(4)(5))(4)(5))
const fizzbuzz = i => j => {
let x = fizz(i) ? cccc(magic) : i
x = buzz(i) ? rin(x)(cccc(witchcraft)) : x
return i < j ? x + '\n' + fizzbuzz(i+1)(j) : x
}
console.log(fizzbuzz(1)(100))
@AlexDunmow
Copy link

Wow this is now truly horrible.

So bad it's !!good.

@nii236
Copy link

nii236 commented Nov 29, 2017

Looking good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment