A magician places n coins on a table and walks down off the stage. A volunteer comes, turns over whichever coins he wishes, selects one coin and whispers its number to the apprentice. Then the apprentice turns over one coin aiming to assist the magician to know the selected coin.
For which values of n the magic will always succeed? What if the apprentice may turn at most one coin?
For the first question: (For which values of n the magic will always succeed?)
Answer: We have $n$ coins which can be in $2$ different states - hands or tails, thus there's $2^n$ coin states.
Let's make the coin's number as its binary representation with number of bits that is equal to the chosen $n$.
The assistant will do the XOR operation with the coins that their heads match the coin that has selected. This will be achieved by using the bitwise XOR of current state with the coin that was selected (by the volunteer) and flipping the coin with that number.
To conclude, $n$ has to be a factor of $2^n$, meaning that $n$ has to be a power of $2$. Flipping the $0$ coin is free, so the assistant can flip a coin whenever he wants.
I thought also about approach with representing the $2^n$ states with a hypercube, we'll give each vertex a color to represent one of the $n$ named coins. There must be one of each color adjacent to any starting position, so there are equal number of each color. Thus, as stated above $n$ must be a factor of $2^n$, thus $n$ must be a power of $2$.
I'm interested to know for which values of $n$ the magic will succeed when the apprentice may turn at most one coin.