Created
September 22, 2015 17:00
-
-
Save QuantumFractal/1fef85250db887c2eb77 to your computer and use it in GitHub Desktop.
This file contains 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 main(): | |
cases = int(input()) | |
for case in range(cases): | |
print(deletions(input())) | |
def deletions(s): | |
# Set our first char | |
last = s[0] | |
new = last | |
# Go through the rest of the chars | |
for c in s[1:]: | |
# Don't add it if it's a dupe | |
if last != c: | |
new += c | |
last = c | |
# Check the lengths to determine the deletions needed | |
return len(s)-len(new) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment