Simple Fun #180: Repeat Adjacent
Description:
Task
You are given a string s
.
Let us call a substring of s
with 2 or more adjacent identical letters a group (such as "aa"
, "bbb"
, "cccc"
...).
Let us call a substring of s
with 2 or more adjacent groups a big group (such as "aabb","bbccc"
...).
Your task is to count the number of big groups
in the given string.
Examples
"ccccoodeffffiiighhhhhhhhhhttttttts"
=>3
The groups are "cccc", "oo", "ffff", "iii", "hhhhhhhhhh", "ttttttt".
The big groups are "ccccoo", "ffffiii", "hhhhhhhhhhttttttt".
"gztxxxxxggggggggggggsssssssbbbbbeeeeeeehhhmmmmmmmitttttttlllllhkppppp"
=>2
The big groups are :
"xxxxxggggggggggggsssssssbbbbbeeeeeeehhhmmmmmmm" and "tttttttlllll"
"soooooldieeeeeer"
=>0
There is no
big group
.
Input/Output
[input]
strings
A string of lowercase Latin letters.
[output]
an integerThe number of big groups.
Similar Kata:
Stats:
Created | Mar 3, 2017 |
Published | Mar 3, 2017 |
Warriors Trained | 1502 |
Total Skips | 39 |
Total Code Submissions | 2506 |
Total Times Completed | 530 |
JavaScript Completions | 202 |
C# Completions | 73 |
Python Completions | 243 |
Ruby Completions | 38 |
Crystal Completions | 10 |
Haskell Completions | 12 |
Total Stars | 38 |
% of votes with a positive feedback rating | 95% of 154 |
Total "Very Satisfied" Votes | 139 |
Total "Somewhat Satisfied" Votes | 14 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |