human
Count of three non | Function that returns true if s [ i ... j ] + s [ k ... l ] + s [ p ... q ] is a palindrome.
Function to return the count of valid sub - strings.
To store the count of required sub - strings.
For choosing the first sub - string.
For choosing the second sub - string.
For choosing the third sub - string.
Check if the concatenation is a palindrome.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count of three non and the other steps required.
 def isPalin ( i , j , k , l , p , q , s ) :
	start = i ; end = q ;
	while ( start < end ) :
		if ( s [ start ] != s [ end ] ) :
			return False ;
		start += 1 ;
		if ( start == j + 1 ) :
			start = k ;
		end -= 1 ;
		if ( end == p - 1 ) :
			end = l ;
	return True ;
def countSubStr ( s ) :
	count = 0 ;
	n = len ( s ) ;
	for i in range ( n - 2 ) :
		for j in range ( i , n - 2 ) :
			for k in range ( j + 1 , n - 1 ) :
				for l in range ( k , n - 1 ) :
					for p in range ( l + 1 , n ) :
						for q in range ( p , n ) :
							if ( isPalin ( i , j , k , l , p , q , s ) ) :
								count += 1 ;
	return count ;
if __name__ == " _ _ main _ _ " :
	s = " abca " ;
	print ( countSubStr ( s ) ) ;