Skip to content

Instantly share code, notes, and snippets.

@c-yan
Created November 16, 2019 00:54
Show Gist options
  • Save c-yan/6b874e13f4d7b1ab2c2fc9e00b4ca76b to your computer and use it in GitHub Desktop.
Save c-yan/6b874e13f4d7b1ab2c2fc9e00b4ca76b to your computer and use it in GitHub Desktop.
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