The king is very angry at his two best mathematicians, so he decrees the following punishment:
The mathematicians will be imprisoned in towers at opposite ends of the kingdom. Each morning, a guard at each tower will flip a coin and show the result to his prisoner. Each prisoner must then guess the result of the coin flip at the other tower. If at least one of the two guesses is correct, they will live another day. But as soon as both guesses are incorrect, they will be executed.
The two mathematicians, as they were being ushered out the door of the castle, came up with a clever plan so that they will always be able to make at least one correct guess. What was their plan?
Mathematician A will always guess the result of his own flip, and mathematician B will always guess the opposite of his own flip. This will guarantee that at least one guess will always be correct.
There are 4 possible results to the coin flips. The results of the two coin flips must either be the same (head-head, tail-tail) or opposite (head-tail, tail-head).
If the coin flips were the same, then Mathematician A who guessed the same would be correct.
If the coin flips were the opposite, then Mathematician B who guessed the opposite would be correct.