6 kyu

Simple Fun #180: Repeat Adjacent

243 of 530myjinxin2015

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] string s

    A string of lowercase Latin letters.

  • [output] an integer

    The number of big groups.

Algorithms

Stats:

CreatedMar 3, 2017
PublishedMar 3, 2017
Warriors Trained1502
Total Skips39
Total Code Submissions2506
Total Times Completed530
JavaScript Completions202
C# Completions73
Python Completions243
Ruby Completions38
Crystal Completions10
Haskell Completions12
Total Stars38
% of votes with a positive feedback rating95% of 154
Total "Very Satisfied" Votes139
Total "Somewhat Satisfied" Votes14
Total "Not Satisfied" Votes1
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • GiacomoSorbi Avatar
  • user5036852 Avatar
  • JohanWiltink Avatar
  • monadius Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • AntonTimofeev Avatar
  • tobeannouncd Avatar
  • XoRMiAS Avatar
  • saudiGuy Avatar
Ad