I once came across the following riddle: (assume $N$ to be extremely large)
There are $N$ perfect logicians arranged in a vertical row. They are allowed to strategize before the game, during the game they are barred from communicating. In the game, the lights are switched off, and a single hat, either red or blue, is placed on the heads of each of the logicians. The lights are turned on; each logician can see the hat colours of all the people in front of him, he can't see the colour of his own hat, or the people behind him. Start with the person at the back, each logician has to call out a colour (heard by all). If his own hat is of that colour, he is spared, otherwise, silently killed. The same is done by the next person, and so on, right till the first person. How many logicians can you guarantee to save, irrespective of the initial colours or any probability?
The answer was simple. The first logician would sacrifice his life. He would call out red if there are an even number of red hats in front of him, and black if there an odd number of red hats. After him, each logician can correctly tell the colour of his own hat.
I decided to give the question a twist. Suppose there is a blind man among the logicians. His life is worth as much as anyone else, and he is placed randomly in the queue. How many logicians can you guarantee to save?
The same approach wouldn't work because, if the blind man gave the wrong colour, not only him, but all the people in front of him will give the wrong colour as they depend on his information also.
After a lot of thinking, I finally came up with this solution.
Find the smallest $n$ such that $3(n+1)+2^n \geq N$. The first $3(n+1)$ people (from the back) will be the ones sacrificing their lives (Group A), and the rest ($2^n$) will try to figure out their own hat colours (Group B). Starting with the back of Group B, assign each logician an ($n+1$)-digit binary number, starting with a string of zeroes, and adding $1$ to get the next logician's ID. Note that the first digit will always be a $0$.The first Group is divided into $n+1$ subgroups of $3$ logicians each. Each subgroup is assigned a normal decimal number $1,2,3,\cdots$ and so on (again starting from the back). Let the subgroup number of a logician be $k$
When the game starts, each Group A logician will look at all the people in Group B, whose $k^{th}$ binary digit is $1$. Of these people, if there are an even number of red hats, he will say red, otherwise he will say blue. The other $2$ logicians in his subgroup will give exactly the same information as the first one. This is necessary to confirm that he is saying the truth, if there is a discrepancy among the $3$ answers, the information given by $2$ is correct, and the third one is the blind one. The same is done by everyone in Group A.
The people of Group B only try to figure out their own hat colours. Each logician has $n+1$ ways of figuring out his own hat colour. If all of the given data doesn't lead to the same answer, he knows that the blind man is behind him and has already called out a lie. He can then use the first logician's info (first in Group A and the queue itself) to figure out his own colour, since the blind man has for sure been counted by that person.
Is my approach correct and is there a faster one? I hope my question is clear enough.
Note: The blind man knows where is placed, but nobody else knows his position.
I think the Hamming code with extra parity provides a solution. If there are $2^n$ logcians, this requires sacrificing $n$ of them (each with chance $1/2$). Let the rear $n$ be the parity bits of the code, called out by those logicians. All the rest can run the error detection scheme. If no bits are wrong yet, either because the blind logician has not spoken or because he was right, each person can find the hat color that has no errors. If one bit is wrong already, one of the hat choices will make two errors, which are detectable by the code.
If the ones behind the blind man can see where he is, you can save all but maybe 2. The rear logician announces the color of the blind man's hat. The next one announces the parity of all the hats he can see. Everybody else is saved by the original solution. If the blind man is at the back, it is not a problem. If the blind man is second, the first announces the color he should say for the parity.
Your approach is correct but not optimal. For large $n$, it requires the sacrifice of $3 \log_2 n$ logicians, while my first paragraph requires the sacrifice of $\log_2 n$. As you say, you are repeating every bit three times, which guarantees the correct answer will be a majority if only one bit is flipped. This exploits the fact that the Hamming distance between $000$ and $111$ is three. Flipping one bit will leave you distance $1$ from the correct string and distance $2$ from the incorrect string. The code I cited at the start does the same thing with $n$ bit code words. All the acceptable ones are at least a distance $4$ from any other, so you can correct single bit errors and detect two bit errors.
Added: We can do it with at most three being sacrificed. You do the classic solution that does not involve the blind logician. The rear one guesses the color that would make the number of red hats even, and is sacrificed with probablity $1/2$. Each one in turn adds the number of red hats he sees to the number of red guesses he has heard. If even, he guesses blue. If odd, he guesses red. All (except maybe the first) will be right. Now we add in the blind logician, who guesses randomly. If the blind man is wrong, the next after him will be wrong, but that restores the parity and the rest are saved. We now lose at most three (the first, the blind man, and the next).