text is made only of the letters a, b and c. Count its contiguous pieces (substrings) in which each of the three letters appears at least once.
Pieces with the same content at different positions are counted separately.text='abca' → 3
"abc", "abca" and "bca" qualify. Every other piece misses at least one letter.
text='ccab' → 2
Any valid piece must include the final "ab" and at least one "c" before it: "cab" and "ccab".
text='aabb' → 0
There is no "c" at all, so the answer is 0.
text contains only a, b and ctext='abca'
3
Run checks the first 3 tests in your browser. Submit checks all 133 tests on the server, hidden ones included.