So, quite a long time ago I ran into a rather interesting puzzle:
The vile invaders captured the village of mega brains, lined them up one after the other so that each previous one sees all the others. For each mega brain, they put on a black or white cap so that not a single megamind can see its cap. Starting from the very last one (the one who sees everyone except himself), each mega brain is asked to take turns asking the color of his hat, if he makes a mistake, they kill him. But just in this case the megamind was agreed in advance on how to minimize the number of people killed. What did the megamozgos agree on?
(all refer to braingames.ru, but in fact this site is a sneaky plagiarist, an ancient problem, they remade it to their own specifics, they added mega brains everywhere, and they gave me their own)
At first, it seemed that half of those killed were joy for this village. But, after thinking a bit, I came across (one girl came across me) on a rather simple solution: the brains agree in advance and if the color in front of it is white, then your color is pronounced (sorry, the first mega brain, you die 50% of the time) otherwise, be quiet. But this is a primitive, although it already gives the result twice as good - 99 mega-brain remains alive.
Now my final version: the last one, which sees everyone, considers a pair, for example, black ones. If you get a pair, he says that he is black. He is unfortunately the only one who risks perishing. The next one considers the pairing of black, if it is pair, it is white (the number of blacks has not changed), otherwise it is black, the next one is similar.
I was amazed at the solution of this task that a truly amazing result was achieved - at first it seemed that saving at least 50% was an excellent result, however, by sacrificing the life of just one of the mega-brains (in 50% of cases), you can surely save everyone else!