Skip to content
User Avatar
#921
Auto-translated
Okay, here's the solution.

It is indeed possible to save 99 wise men.

The wise men agree to assign a numerical value to each color, for example, red - 0, white - 1, blue - 2.

The first wise man calculates the sum modulo 3 of the color values of all the wise men standing in front of him:
(0+0=0
0+1=1
0+2=2
1+1=2
1+2=0
2+2=1) and says the color corresponding to this number. (Hopefully, it will match the color of his hat.) The second wise man calculates the sum modulo 3 of the color values of all the wise men standing behind him and subtracts it modulo 3 from the number said by the first wise man:

(0-1=2
0-2=1
1-0=1
1-1=0
1-2=2
2-0=2
2-1=1
2-2=0). He then determines the color of his hat. The third wise man subtracts from the number said by the first wise man the sum modulo 3 of all the wise men standing behind him and the number said by the second wise man (the color of the second wise man's hat). The fourth wise man subtracts modulo 3 from the number said by the first wise man the sum of the answers given by the second and third wise men and the sum modulo 3 of the colors of all the wise men standing behind him, and so on. That is, the J-th wise man determines his color:

cj=a1-(a2+a3+...+aj-1)-(cj+1+cj+2+...+c100)

c - colors, and a - the answers of the wise men.
Starting with the second wise man, the answers will definitely match the colors.
All arithmetic operations must be performed modulo 3.

Uranium came closest to the answer, so let him be the one to solve it, although Yaschur also did a great job and probably guaranteed to save 75 wise men.

Added 10 minutes later
P. S. And I also have a thought that it is generally possible to save any number of wise men with any number of hat colors. You just need to add modulo a larger number - the number of hat colors.
Всё не так плохо как Вы думаете. Всё намного хуже!