Find array whose elements are XOR of adjacent elements in given array | Function to reconstruct the array arr [ ] with xor of adjacent elements ; Iterate through each element ; Store the xor of current and next element in arr [ i ] ; Function to print array ; Driver Code ; Inputs ; Length of the array given ; Function call to reconstruct the arr [ ] ; Function call to prarr [ ]
def game_with_number ( arr , n ) : NEW_LINE INDENT for i in range ( n - 1 ) : NEW_LINE INDENT arr [ i ] = arr [ i ] ^ arr [ i + 1 ] NEW_LINE DEDENT return arr NEW_LINE DEDENT def printt ( arr , n ) : NEW_LINE INDENT print ( * arr ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT arr = [ 10 , 11 , 1 , 2 , 3 ] NEW_LINE n = len ( arr ) NEW_LINE new_arr = game_with_number ( arr , n ) ; NEW_LINE printt ( new_arr , n ) NEW_LINE DEDENT