human
Make Array elements equal by replacing adjacent elements with their XOR | Function to check if it is possible to make all the array elements equal using the given operation.
Stores the XOR of all elements of array A [ ].
Case 1 , check if the XOR of the array A [ ] is 0.
Maintains the XOR till the current element.
Iterate over the array.
If the current XOR is equal to the total XOR increment the count and initialize current XOR as 0.
Print Answer.
Driver Code.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to make Array elements equal by replacing adjacent elements with their XOR and the other steps required.
 def possibleEqualArray ( A , N ) :
	tot_XOR = 0
	for i in range ( N ) :
		tot_XOR ^= A [ i ]
	if ( tot_XOR == 0 ) :
		print ( " YES " )
		return
	cur_XOR = 0
	cnt = 0
	for i in range ( N ) :
		cur_XOR ^= A [ i ]
		if ( cur_XOR == tot_XOR ) :
			cnt += 1
			cur_XOR = 0
	if ( cnt > 2 ) :
		print ( " YES " )
	else :
		print ( " NO " )
if __name__ == ' _ _ main _ _ ' :
	A = [ 0 , 2 , 2 ]
	N = len ( A )
	possibleEqualArray ( A , N )