I’m going to assume minimal mathematical background; I apologize if I’ve pitched this way too low. One classic solution works like this.
The prisoners number the colors $0$ through $6$; say red $=0$, orange $=1$, yellow $=2$, and so on through violet $=6$. They also number themselves $0$ through $6$; I’ll simply call them $P_0,P_1,\dots,P_6$. When the hats are put onto their heads, each prisoner performs the following calculation: he adds up the numbers of the colors of the six hats that he can see and subtracts that from his own personal number. For example, if $P_3$ sees hats with colors $0,2,2,5,5$, and $6$, he calculates $$3-(0+2+2+5+5+6)=-17\;.$$ Then he reduces this modulo $7$ to a number in the range from $0$ through $6$. If you’re not familiar with modular arithmetic, that simply means that he adds or subtracts $7$ repeatedly until he gets a number in the desired range. In this case $-17+3\cdot7=4$ is the final result. This is the number corresponding to the color blue, so he writes down blue. The claim is that if every prisoner follows this procedure, one will write down the name of the color of his own hat.
Here’s why it works. Note first what happens if $P_3$’s hat really is blue: then the hat colors add up to $$0+2+2+5+5+6+4=24\;,$$ and when we reduce this modulo $7$ we get $24-3\cdot7=3$, $P_3$’s personal number. The procedure ensures that this happens with each prisoner: he guesses the hat color that would make the sum of all seven hat colors equal (modulo $7$) to his own personal number.
Whatever the actual colors of the hats, their numbers must add up (modulo $7$) to one and only one of the seven numbers $0,1,2,3,4,5$, or $6$. Say they add up to $k$. Then $P_k$ and only $P_k$ writes down the color that makes the total correct. Every other prisoner writes down a color corresponding to one of the other six possible totals. Let’s say that $P_k$ wrote down color number $c_1$, that his own hat’s color is number $c_2$, and that the color numbers of the six hats that he could see added up to $t$. Then on the one hand the procedure ensures that he chose $c_1$ to make $t+c_1$ equal to his own number, $k$, modulo $7$, and on the other hand we know that $k$ is the actual total of the seven color numbers, so $t+c_2$ is equal to $k$ modulo $7$. In short, $t+c_1$ and $t+c_2$ reduce to the same number modulo $7$, so $c_1=c_2$: he wrote down the color of his own hat.
For the follow-up you have to assume that success will be announced after each try if you manage. We assume that a malevolent adversary controls the rotation, but you can flip a single coin, an opposite pair, or an adjacent pair at your option. You just can't keep track of anything except relative position between flips. You start knowing they are not all heads or all tails. Flip two opposite coins. If that doesn't work, you either have an odd number of heads or two adjacent heads. Flip two neighboring coins. If that doesn't work, you either have two opposite heads or an odd number of heads. Flip two opposite coins. If that doesn't work, you have an odd number of heads. Note that so far, we have always flipped an even number, so the parity hasn't changed. Flip one coin. If that doesn't work, you have two heads and two tails. Flip two opposite coins. If that doesn't work, you have two neighboring heads. Flip two adjacent. If that doesn't work, you have two opposite heads. Flip two opposite. Guaranteed to work.
If success is all heads instead of all the same, put flip all four at the start and after every step of the above.
Best Answer
The only place having at least 23 tiles in sight is in the centre, so we must place black 23 there. Also in sight of black 23 and blue 3059 must be green 3059.
All tiles in sight of black 23 becomes red except one that can be potentially green 3059.
Our green 121121 have in sight 3 tiles that can be black - we must place in them two 11s and one 13. It is easy to see, that one of them already have 12 red tiles in sight, so we place black 13 there and remaining 11s in two remaining tiles. Colour two tiles next to 13 and 11 red.
Green $847=7\cdot 11^2$ have in its sight black 7 and two black 11s - in its sight there should be no more black tiles.
Red 843 have in its sight only one tile that can be blue - put there blue 847.
Blue 847 requires green 847 - there is only one tile in sight of blue 847 that can be green - put green 847 there.
Blue 7 requires green 7 - there are two tiles that can be green, but only one gives 7 - put green 7 there.
Red 3997 requires 3150 in blues - put blue 3059 and blue 91 in sufficient tiles.
Blue 91 requires green 91 - there is only one tile where we can put green 91.
There is one more place, where could be green 77, but it will collide with blue 7. Just leave this place empty.