There are many red, orange, yellow, green, blue, indigo and violet hats in the prison. 1 day, 7 pirates were caught and was brought to the prison. They warden said,"I will put a hat on your head tonight( with possible colour repetition), and you will be arranged to sit around a round table. each of you can see other hats of your gang, but not yours. Everyone will guess their colour of their hat, and if someone is correct, everyone will be free, or else everyone will be executed. You have until tonight to discuss your strategy." Is there a way to ensure everyone stays alive?
(I think I tag the wrong tag, so help me to edit it.)