Skip to content

Instantly share code, notes, and snippets.

@folkengine
Last active July 28, 2016 13:52
Show Gist options
  • Save folkengine/8cdd87130716a688e7fe to your computer and use it in GitHub Desktop.
Save folkengine/8cdd87130716a688e7fe to your computer and use it in GitHub Desktop.
FizzBuzz Python
import sys
def fb(f, b, count):
fizz = int(f)
buzz = int(b)
c = int(count)
for x in range(1, c + 1):
if x != 1:
print(' ', end="")
if (x % fizz == 0) and (x % buzz == 0):
print('FizzBuzz', end="")
elif x % fizz == 0:
print('Fizz', end="")
elif x % buzz == 0:
print('Buzz', end="")
else:
print(x, end="")
print()
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
s = test.split()
fb(s[0], s[1], s[2])
test_cases.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment