Prisoners and hats is a logic puzzle based on inductive and deductive reasoning, depending on which prisoner you are. The puzzle is as follows: Four prisoners have been captured, but the prison is full. The jailer's a cruel person, and gives these 4 prisoners a puzzle they have to solve. If they succeed, they go free. If they don't, they'll be executed.
The jailer puts 3 people in a line, and the fourth behind a wall. Each person also has a hat placed on their heads, two of which are white, and two of which are black. Each prisoner can only see the hat of the people in front of them, assuming there is somebody there. So the person in front, and the person behind the wall can't see anybody. Communication isn't allowed.
If any prisoner can tell with 100% accuracy which hat they have on their own head, all 4 of them go free. How do they do it?
This puzzle can obviously be adapted into an RPG setting very easily. You don't even have to worry about trying to negate spells and other abilities, the jailer (and perhaps some guards) will simply punish the use of such skills.
There are more variants of this puzzle too, including one with 3 hats of the same color, and one that's different, one with 3 black, and 2 white hats, several versions in which the prisoners have also been deafened (see solution below why this matters), and so on.
The solution is pretty simple. Let's say the hats were dealt like in the image above, so white, black, white, black. Person 1 would see black, then white, and then the wall. This means person 1 has no way of knowing which hat they have. If both hats in front of them were the same color, they would know which hats all the prisoners have, as there's only 1 color left.
But in this case person 1 will stay quiet. Person 2 can see a white hat, and, after giving person 1 enough time, will hopefully realize person 1 sees two different hats, and is therefore unable to answer. This means person 2's hat must be different from person 3, and therefore it must be black.
The solutions to some of the variants rely entirely on biggest chances, rather than absolute certainties. These puzzles rely on inductive reasoning, and aren't all that ideal for RPG settings. They can seem unfair because they're based on chance, but they could still make for a fun challenge.
One such puzzle is when you have 3 prisoners, each with a random hat. The hats are either black or white. The hats are given randomly, and there's no maximum amount of hats of any color. Each prisoner has to answer at the same time, but can choose to remain silent. Silence doesn't count as a wrong answer, but at least 1 person has to give the right answer, and nobody can give a wrong answer. Each prisoner can only see the hats of the others, not their own. Communication isn't allowed in any form. How do they get their freedom back?
In some variations of this puzzle the prisoners are allowed to come up with a plan beforehand, but before they've been given their hats obviously.
There's no answer to this that'll guarantee their freedom 100% of the time. Two could remain silent, and let the third guess. It'd be a 50-50 chance, but the odds can be bigger. The biggest chance you'll have is one of 75% certainty, which has to do with how many possible distributions there are of the hats. You could have 3 black hats, 3 white hats, 2 black hats and a white hat, and 2 white hats and a black hat. But the combinations of 2 + 1 can happen three times for each (black-black-white, black-white-black, white-black-black, etc.), which means the chances of being dealt two of the same hat, and one different hat are bigger than being dealt 3 of the same hat.
With this knowledge you should answer as follows: If you see two of the same hats, answer the opposite color. If you see two different hats, don't answer. This gives you a 75% chance to win your freedom, rather than the 50% random chance of the other method.
This can still make for a fun puzzle with some groups, but instead of execution or imprisonment you could make them fight a monster in one on one combat instead for example.