Skip to content

Instantly share code, notes, and snippets.

@LXZE
Last active April 12, 2016 17:52
Show Gist options
  • Save LXZE/02a825b44dc17157ef87c0b89a1db0c0 to your computer and use it in GitHub Desktop.
Save LXZE/02a825b44dc17157ef87c0b89a1db0c0 to your computer and use it in GitHub Desktop.
Google Codejam 2016 Qualification round : Counting sheep
f = open("input.in","r")
w = open("output.txt","w")
num = f.readline()
for it in range(0,int(num)):
res = ''
num = int(f.readline())
if num == 0:
res = 'INSOMNIA'
else:
idx = 0
txt = ''
val = num
found = False
ite = 99
while idx<ite:
txt += str(val)
if(len(set(str(txt)))<10):
val += num
idx+=1
else:
res = val
found = True
break
if not found:
res = 'INSOMNIA'
print("Case #{0}: {1} ".format(it+1,res))
w.write("Case #{0}: {1}\n".format(it+1,res))
w.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment