Count Vowel Pairs
EasyPractice library · +10 XPstringsloopscounting
Given a string $S$ consisting of lowercase English letters, count the number of pairs of adjacent characters that are the same. For example, in the string 'aabbc', the pairs are 'aa' and 'bb', so the count is 2.
Input
A single line containing the string $S$.
Output
A single integer, the count of adjacent identical character pairs.
Constraints
The length of $S$ is between 1 and 1000, inclusive. $S$ consists only of lowercase English letters ('a'-'z').
Time limit 1 s (native code; slower languages get more)Memory 256 MB14 hidden tests
Example 1
Input
aabbc
Output
2
Pairs 'aa' and 'bb' result in a count of 2.
Example 2
Input
abcde
Output
0
No adjacent characters are the same, so the count is 0.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
aabbc
Example 2 input
abcde