Skip to content

Instantly share code, notes, and snippets.

@yuheiomori
Last active October 3, 2015 19:38
Show Gist options
  • Save yuheiomori/2514429 to your computer and use it in GitHub Desktop.
Save yuheiomori/2514429 to your computer and use it in GitHub Desktop.
CodeEval Multiples of a Number
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