human
Count number of substrings of a string consisting of same characters | Function to return the number of substrings of same characters.
Size of the string.
Initialize count to 1.
Initialize left to 0 and right to 1 to traverse the string.
Checking if consecutive characters are same and increment the count.
When we encounter a different characters.
Increment the result.
To repeat the whole process set left equals right and count variable to 1.
Store the final value of result.
Driver code"
Solution in Python:
 ... Give me a code to count number of substrings of a string consisting of same characters and the other steps required?
assistant
#Here is code to count number of substrings of a string consisting of same characters and the other steps required.
 def findNumbers ( s ) :
	n = len ( s )
	count = 1
	result = 0
	left = 0
	right = 1
	while ( right < n ) :
		if ( s [ left ] == s [ right ] ) :
			count += 1
		else :
			result += count * ( count + 1 ) // 2
			left = right
			count = 1
		right += 1
	result += count * ( count + 1 ) // 2
	print ( result )
s = " bbbcbb "
findNumbers ( s )