Created
July 1, 2010 18:07
-
-
Save paulosuzart/460318 to your computer and use it in GitHub Desktop.
This file contains 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
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