Skip to content

Instantly share code, notes, and snippets.

@jckw
Created April 10, 2016 10:12
Show Gist options
  • Save jckw/6c54019a10e897bb181fe768b3e20a61 to your computer and use it in GitHub Desktop.
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)
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))
@s0nskar
Copy link

s0nskar commented Aug 27, 2016

I think INSOMNIA should be printed only for input 0. correct me if I am wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment