Skip to content

Instantly share code, notes, and snippets.

@Polydynamical
Last active August 3, 2023 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Polydynamical/d973f0815b559e7bd2635ada1f8d1a22 to your computer and use it in GitHub Desktop.
Save Polydynamical/d973f0815b559e7bd2635ada1f8d1a22 to your computer and use it in GitHub Desktop.
Branchless 1-line Solution to FizzBuzz
for n in range(1, 101): print("fizz" * (n % 3 == 0) + "buzz" * (n % 5 == 0) + ((n % 3 != 0) and (n % 5 != 0)) * str(n));
@leed25d
Copy link

leed25d commented Jun 6, 2021

doesn't work should be range(1, 101).

I got called on that in an interview once.

@Polydynamical
Copy link
Author

Polydynamical commented Jun 6, 2021

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