Skip to content

Instantly share code, notes, and snippets.

@kikers25
Created February 27, 2017 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikers25/6d9ad3d206644078e4bc2b9f864eb756 to your computer and use it in GitHub Desktop.
Save kikers25/6d9ad3d206644078e4bc2b9f864eb756 to your computer and use it in GitHub Desktop.
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