Created
November 16, 2019 00:54
-
-
Save c-yan/6b874e13f4d7b1ab2c2fc9e00b4ca76b 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
s = list(input()) | |
i = 0 | |
result = 0 | |
while i < len(s) - 2: | |
if s[i] != 'A': | |
i += 1 | |
continue | |
if s[i + 1] == 'B' and s[i + 2] == 'C': | |
result += 1 | |
s[i] = 'B' | |
s[i + 1] = 'C' | |
s[i + 2] = 'A' | |
if i != 0: | |
i -= 1 | |
else: | |
i += 1 | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment