Skip to content

Instantly share code, notes, and snippets.

@jamesandariese
Created August 24, 2015 21:53
Show Gist options
  • Save jamesandariese/e08b042d845fe422c13a to your computer and use it in GitHub Desktop.
Save jamesandariese/e08b042d845fe422c13a to your computer and use it in GitHub Desktop.
Fizzbuzz in python
[print({0:'FizzBuzz',32:'Fizz',16:'Buzz'}.get(0-n%3&16|0-n%5&32,n)) for n in range(1,101)]
#
# 0001
# 1111
# 1100 & 1000 = 1000
#
# 1 & 1 = 1
# 1 & 0 = 0
# 0 & 0 = 0
# 0 & 1 = 0
#
# 11 & 11 = 11
# 10 & 11 = 10
# 01 & 11 = 01
# 00 & 10 = 00
#
# 000000 & 100000 = 000000
# 111110 & 100000 = 100000
@jamesandariese
Copy link
Author

it's a thing.

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