human
Variation in Nim Game | Function to return final grundy Number ( G ) of game.
if pile size is odd.
We XOR pile size + 1.
if pile size is even.
We XOR pile size - 1.
Game with 3 piles.
pile with different sizes.
Function to return result of game.
if ( res == 0 ) : if G is zero.
else : if G is non zero"
How can the above be solved in Python?

=====
What is a code to variation in Nim Game and the other steps required?
assistant
#Here is code to variation in Nim Game and the other steps required.
 def solve ( p , n ) :
	G = 0
	for i in range ( n ) :
		if ( p [ i ] % 2 != 0 ) :
			G ^= ( p [ i ] + 1 )
		else :
			G ^= ( p [ i ] - 1 )
	return G
n = 3
p = [ 32 , 49 , 58 ]
res = solve ( p , n )
	print ( " Player ▁ 2 ▁ wins " )
	print ( " Player ▁ 1 ▁ wins " )