Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Counting Sheep
def addingCase(n, text):
resultCase = "Case #" + str(n) + ": " + text + "\n"
print resultCase
return resultCase
def findLastNumber(n):
numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
i = 1
result = str(n)
while (len(numbers) > 0):
result = str(n * i)
# print str(n) + " * " + str(i) + " is " + result
for nI in result:
if (nI in numbers):
numbers.remove(nI)
i = i + 1
return result
inFile = open("A-large-practice.in", "r")
outFile = open("A-large-practice.out", "w")
t = int(inFile.readline())
print "t is ", t
icase = 1
while icase <= t:
n = int(inFile.readline())
print "n is " + str(n)
if (n == 0):
outFile.write(addingCase(icase, "INSOMNIA"))
else:
outFile.write(addingCase(icase, findLastNumber(n)))
icase = icase + 1
outFile.close()
inFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment