Last active
October 3, 2015 17:18
-
-
Save yuheiomori/2493458 to your computer and use it in GitHub Desktop.
codeeval fizzbuzz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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