human
Find number of substrings of length k whose sum of ASCII value of characters is divisible by k | Python3 program to find number of substrings of length k whose sum of ASCII value of characters is divisible by k.
Finding length of string.
finding sum of ASCII value of first substring.
Using sliding window technique to find sum of ASCII value of rest of the substring.
checking if sum is divisible by k.
Driver code"
Solution in Python:
 Give me a code to find number of substrings of length k whose sum of ASCII value of characters is divisible by k and the other steps required?
assistant
#Here is code to find number of substrings of length k whose sum of ASCII value of characters is divisible by k and the other steps required.
 def count ( s , k ) :
	n = len ( s )
	d , count = 0 , 0
	for i in range ( k ) :
		d += ord ( s [ i ] )
		if ( d % k == 0 ) :
			count += 1
			for i in range ( k , n ) :
				prev = ord ( s [ i - k ] )
				d -= prev
				d += ord ( s [ i ] )
				if ( d % k == 0 ) :
					count += 1
					return count
s = " bcgabc "
k = 3
ans = count ( s , k )
print ( ans )