Here's my solution:
He knows number 4 sees two different coloured hats, and what colour number 2's hat is.
This is my favourite challenge problem, simply because it only requires pure logic, nothing else.
Look at this diagram: http://img179.imageshack.us/img179/769/4soldiers.png
There are four prisoners, buried to their necks in the ground. Each of them is wearing a hat. They know that there are four of them. They know that each prisoner is wearing just one hat. The prisoners know that there are two black hats and two white hats. They cannot turn their heads even the slightest, they can only look straight ahead.
The arrows on the diagram indicate the direction of their heads.
Prisoner 1 can only see the brick wall.
Prisoner 2 can only see the brick wall.
Prisoner 3 can see Prisoner 2 and the brick wall.
Prisoner 4 can see Prisoner 3, Prisoner 2 and the brick wall.
From Prisoner 1 to Prisoner 4 (i.e. left to right), the hats have been arranged white-black-white-black. The prisoners do NOT know this.
The prisoners do not know what colour hat is on their head.
The guard has told the prisoner that each of them can only speak one word: either 'black' or 'white'. If what the prisoner says is the correct colour of the hat on his head, then all of them are freed. If what the prisoner says is incorrect, all four of them are killed instantly.
Only one prisoner out of the four can work out what out what colour hat is on his head.
Who is it and why?
(The answer is NOT that one of them takes a lucky guess).
Answer to problem:
Having said that, Musab, 3 doesn't know that 4 is seeing two different colours. But you have to think about the question asked. You, the askee of the problem, know that the hats are in an alternating pattern. With this restriction, 3 is the ONLY logical answer to the problem.
If 2 and 3 were the same coloured, then 4 would be the only logical answer to the problem. But the fact is, the hats are alternating.
I don't know how much sense that makes.... but YOU know that the hats are alternating. The soldiers do not.
Wow, I'm not even sure I'm answering your question... I guess you could argue that if all the soldiers are highly intelligent and a lot of time passes, 3 could assume that 4 would have said something by now if 2 and 3 were the same.