human
Number of triplets in array having subarray xor equal | Function to return the count.
Initialise result.
Pick 1 st element of the triplet.
Pick 2 nd element of the triplet.
Pick 3 rd element of the triplet.
Taking xor in the first subarray.
Taking xor in the second subarray.
If both xor is equal.
Driver Code.
Function Calling"
How can the above be solved in Python?
assistant
#Here is code to number of triplets in array having subarray xor equal and the other steps required.
 def xor_triplet ( arr , n ) :
	ans = 0 ;
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			for k in range ( j , n ) :
				xor1 = 0 ; xor2 = 0 ;
				for x in range ( i , j ) :
					xor1 ^= arr [ x ] ;
				for x in range ( j , k + 1 ) :
					xor2 ^= arr [ x ] ;
				if ( xor1 == xor2 ) :
					ans += 1 ;
	return ans ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 4 , 5 ] ;
	n = len ( arr ) ;
	print ( xor_triplet ( arr , n ) ) ;