Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
dropbox example q
def rebluebluered(s, pattern):
return search(s, pattern, dict())
def search(left, pattern, matches):
if (not pattern and left) or (pattern and not left):
return False
if not pattern and not left:
return True
pch = pattern[0]
if matches.get(pch):
word = matches[pch]
if left.find(word) == 0:
return search(left[len(word):], pattern[1:], matches)
return False
word = ""
for i, c in enumerate(left):
word += c
matches[pch] = word
print(matches, left, pch)
if search(left[i+1:], pattern[1:], matches):
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.