-
-
Save kikers25/6d9ad3d206644078e4bc2b9f864eb756 to your computer and use it in GitHub Desktop.
Counting Sheep
This file contains 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
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