Last active
August 3, 2023 03:59
-
-
Save Polydynamical/d973f0815b559e7bd2635ada1f8d1a22 to your computer and use it in GitHub Desktop.
Branchless 1-line Solution to FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for n in range(1, 101): print("fizz" * (n % 3 == 0) + "buzz" * (n % 5 == 0) + ((n % 3 != 0) and (n % 5 != 0)) * str(n)); |
Oh wow that's harsh (but I do understand that they can't allow bugs like that), I updated it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doesn't work should be range(1, 101).
I got called on that in an interview once.