Skip to content

Instantly share code, notes, and snippets.

@whizzzkid
Last active February 13, 2017 06:06
Show Gist options
  • Save whizzzkid/9a0bfd3a75a550d7a6842ef6efeb046b to your computer and use it in GitHub Desktop.
Save whizzzkid/9a0bfd3a75a550d7a6842ef6efeb046b to your computer and use it in GitHub Desktop.
# This is done!
size = int(raw_input())
def node():
return [0, {}, 0]
words = node()
ans = 1
for s in xrange(size):
if not ans: break
word = str(raw_input())
root = words
for chr in word:
root[0] = 1
if root[2]:
ans = 0
break
if not root[1].get(chr):
root[1][chr] = node()
root = root[1].get(chr)
if root[0]:
ans = 0
else:
root[0] = 1
root[2] = 1
if ans:
print 'GOOD SET'
else:
print 'BAD SET'
print word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment