Prof goes out and comes back after 20 minutes but nobody was able to answer the question. So he gave them 10 more minuets but the result was the same. So he decides to give them final 5 minutes. When he comes everybody was able to answer him correctly.

So what is the answer? and why?

See Solution : Hats and IIT studentsAfter first interval of 20 minutes :

So there can not be 1 red and 8 black hats.

After second interval of 10 minutes :

So there can not be 2 red and 7 black hats.

After third interval of final 5 minutes :

So there are 3 red hats and 6 black hats.