Last active
October 3, 2015 19:38
-
-
Save yuheiomori/2514429 to your computer and use it in GitHub Desktop.
CodeEval Multiples of a Number
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
import sys | |
def multiple_gen(n): | |
original_n = n | |
while True: | |
n = n + original_n | |
yield n | |
def multiples_of_a_number(x, n): | |
for e in multiple_gen(n): | |
if e >= x: | |
return e | |
if __name__ == '__main__': | |
test_cases = open(sys.argv[1], 'r') | |
for line in test_cases: | |
x, n = [int(e) for e in line.split(',')] | |
print(multiples_of_a_number(x, n)) | |
test_cases.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment