Skip to content

Instantly share code, notes, and snippets.

@ndricca
Created September 29, 2020 09:02
Show Gist options
  • Save ndricca/296f9e6e481ab144ac67b11bd90050cb to your computer and use it in GitHub Desktop.
Save ndricca/296f9e6e481ab144ac67b11bd90050cb to your computer and use it in GitHub Desktop.
MULTIPLES_DICT = {
3: 'Fizz',
5: 'Buzz',
7: 'Wolf',
}
def _is_by_num(num: int, multiple: int) -> bool:
return num % multiple == 0
def _get_string_by_multiple(mult: int ) -> str:
return MULTIPLES_DICT.get(mult)
def fizz_buzz(num: int) -> str:
res = ''
for mult in MULTIPLES_DICT.keys():
if _is_by_num(num, mult):
res += _get_string_by_multiple(mult)
return res if res != '' else str(num)
if __name__ == '__main__':
for i in range(100,110):
print((i,fizz_buzz(i)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment