Created
April 10, 2016 10:12
-
-
Save jckw/6c54019a10e897bb181fe768b3e20a61 to your computer and use it in GitHub Desktop.
Python3 solution to the Counting Sheep Google Code Jam problem (qual round, problem A)
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
no = int(input()) | |
final = [True, True, True, True, True, | |
True, True, True, True, True] | |
for i in range(0, no): | |
total = 0 | |
number = int(input()) # int | |
strNum = str(number) | |
nums = [False, False, False, False, False, | |
False, False, False, False, False] | |
insom = False | |
while nums != final: | |
non_zero = 0 | |
for digit in strNum: | |
if digit != "0": | |
non_zero += 1 | |
nums[int(digit)] = True | |
if non_zero == 0: | |
print("Case #" + str(i + 1) + ": INSOMNIA") | |
insom = True | |
break | |
else: | |
total += 1 | |
strNum = str(int(number) * (total + 1)) | |
if not insom: | |
caseText = "Case #" + str(i + 1) + ": " | |
print(caseText + str(number * total)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think INSOMNIA should be printed only for input 0. correct me if I am wrong