Skip to content

Instantly share code, notes, and snippets.

@yuheiomori
Last active October 3, 2015 17:18
Show Gist options
  • Save yuheiomori/2493458 to your computer and use it in GitHub Desktop.
Save yuheiomori/2493458 to your computer and use it in GitHub Desktop.
codeeval fizzbuzz
# coding=utf-8
import sys
def fizzbuzz(a, b, n):
tmp = []
if n % a == 0:
tmp.append("F")
if n % b == 0:
tmp.append("B")
if len(tmp) == 0:
tmp.append(str(n))
return "".join(tmp)
test_cases = open(sys.argv[1], 'r')
for line in test_cases:
a, b, n = [int(e) for e in line.split()]
print " ".join([fizzbuzz(a, b, i) for i in range(1, n + 1)])
test_cases.close()
test_cases.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment