Skip to content

Instantly share code, notes, and snippets.

@t0yohei
Created June 26, 2021 05:36
Show Gist options
  • Save t0yohei/f456896edf33154e41747d61bea993a6 to your computer and use it in GitHub Desktop.
Save t0yohei/f456896edf33154e41747d61bea993a6 to your computer and use it in GitHub Desktop.
fizzbuzz program without any `if`, `while`, `for` and relational operators such as `==`.
THREE_HASH = {0: "fizz", 1: "", 2: ""}
FIVE_HASH = {0: "buzz", 1: "", 2: "", 3: "", 4: "", 5: ""}
def fb(i):
result = ""
result += THREE_HASH[i % 3]
result += FIVE_HASH[i % 5]
return result
i = 1
while i <= 200:
print(i, fb(i))
i = i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment