Alternative on the Island of Knights and Knaves
An alternative is a person who alternatively tells the truth and a lie. That is, if his statement is true, his next statement is false. Once an alternative visited an island in which each inhabitant is either a "knight" or a "knave".[more]
In this problem there are inhabitants, denoted by A, B, C, … . The alternative makes statements, and the problem is to infer who is a knight and who is a knave.[less]
The algorithm makes random statements about inhabitants and checks that the solution is unique. If after 50 attempts it fails, a message is returned.