<doocs>1180.Count Substrings with Only One Distinct Letter_1.py
def countLetters( s: str) -> int:
    n = len(s)
    i = ans = 0
    while i < n:
        j = i
        while j < n and s[j] == s[i]:
            j += 1
        ans += (1 + j - i) * (j - i) // 2
        i = j
    return ans
def sample_funcname ( var_0 : str ) -> int :
    var_4 = len ( var_0 )
    var_7 = var_5 = 0
    while var_7 < var_4 :
        var_8 = var_7
        while var_8 < var_4 and var_0 [ var_8 ] == var_0 [ var_7 ] :
            var_8 += 1
        var_5 += ( 1 + var_8 - var_7 ) * ( var_8 - var_7 ) // 2
        var_7 = var_8
    return var_5
