Created
July 23, 2013 23:21
-
-
Save darius/6066998 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # My solution to a problem in https://github.com/darius/regexercise | |
| def search(strings, chars): | |
| """Given a sequence of strings and an iterator of chars, return True | |
| if any of the strings would be a substring of ''.join(chars); but | |
| only consume chars up to the end of the match.""" | |
| if not all(strings): | |
| return True | |
| tails = [] | |
| for ch in chars: | |
| tails = [tail[1:] for tail in strings + tails if tail[0] == ch] | |
| if not all(tails): | |
| return True | |
| return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment