Created
September 29, 2014 12:29
-
-
Save alexnad/de1551bdf4f57dd3c7d3 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
| def ABCheck(str): | |
| str = str.lower() | |
| next_a = -1 | |
| next_b = -1 | |
| for position, letter in enumerate(str): | |
| if position == next_a and letter == 'a' or position == next_b and letter == 'b': | |
| return True | |
| if letter == 'a': | |
| next_a = -1 | |
| next_b = position + 4 | |
| if letter == 'b': | |
| next_a = position + 4 | |
| next_b = -1 | |
| return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment