Your answer is correct for a two person scenario, try a similar extension for a scenario with several people.
Yes that is the correct solution. If there are two people with blue hats, they would leave at the second bell ring and so on.
On to the second riddle then /o/
A Logician wants to test his students to see how smart they are. He tells them all to sit around in a circle such that each one can see all the others. He puts a coloured hat on all of them. None of them know what colour hat they wear, nor are they allowed to look at their hat in any way. He sets down the following conditions :
1) The number of colours of hats is indefinite, there could be red, blue,black,white , purple or any other colour.
2) A bell will be rung at regular intervals, if you know what colour your hat is, you can get up and tell me what colour your hat is. If you are correct, you pass. Else you fail.
3) You are not allowed to communicate with each other in any way.
4) If i feel like you should have guessed your hat colour already but haven't, you fail.
5) It is impossible to not guess your hat colour throughout the test.
How do the students correctly guess their hat colours?