Skip to content

Instantly share code, notes, and snippets.

@paulosuzart
Created July 1, 2010 18:07
Show Gist options
  • Save paulosuzart/460318 to your computer and use it in GitHub Desktop.
Save paulosuzart/460318 to your computer and use it in GitHub Desktop.
h = {}
w = ['paulo', 'saulo', 'carolina', 'rafael', 'mauro', 'joao', 'abraao']
[[[(h.has_key(c) and not h[c].append(word)) or not h.update({c : [word]})] for c in word] for word in w]
def search(chars):
s = set([])
[[s.add(w) for w in [e for e in h.get(char) if e.find(chars) >= 0]] for char in chars]
return s
print 'people whose name contains au: ', search('au')
print 'people whose name contains aao: ', search('aao')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment