# The Kalotans are a tribe with a peculiar quirk. Their males always # tell the truth. Their females never make two consecutive true # statements, or two consecutive untrue statements. # An anthropologist (let's call him Worf) has begun to study # them. Worf does not yet know the Kalotan language. One day, he # meets a Kalotan (heterosexual) couple and their child Kibi. Worf # asks Kibi: ``Are you a boy?'' Kibi answers in Kalotan, which of # course Worf doesn't understand. # Worf turns to the parents (who know English) for explanation. One # of them says: ``Kibi said: `I am a boy.' '' The other adds: ``Kibi # is a girl. Kibi lied.'' # Solve for the sex of the parents and Kibi. ae.findall { parentGender1 = ae.amb("M", "F") parentGender2 = ae.amb("M", "F") kibiGender = ae.amb("M", "F") kibiSaid = ae.amb("M", "F") kibiLied = ae.amb(true, false) ae.assert(parentGender1 != parentGender2) if kibiGender == "M" ae.assert(! kibiLied ) end if kibiLied ae.assert( kibiSaid != kibiGender ) else ae.assert( kibiSaid == kibiGender ) end if parentGender1 == "M" ae.assert( kibiSaid == "M" ) end if parentGender2 == "M" ae.assert( kibiGender == "F" ) ae.assert( kibiLied ) else ae.assert( (kibiGender == "F") ^ kibiLied ) end [ parentGender1, parentGender2, kibiGender, kibiSaid, kibiLied ] }