# CS50 AI Puzzel.py Knowledge 2

I am struggling to find a solution for it.My logic is that either A could be Knight or Knave and same with B it could be either a Knight or Knave.Hence the first two Ors. Then my logic is that if A is telling the truth then if A is KNight then either the implication that if A is Knight B will be Knight too would be correct or if A is Knave the implication that B too would be Knave be right. Same with B that if B is telling the truth then if A is a Knave than B can not be a Knave and if A is Knight B can not be night here's my code

``````Or(AKnight, AKnave),
Or(BKnight, BKnave),

And(
Or(
Implication(AKnight,BKnight),
Implication(AKnave, BKnave)
),

Or(
Implication(AKnight, Not(BKnight)),
Implication(AKnave, Not(BKnave))
)
)
``````

Can't seem to figure out what is wrong with my code. Any help would be appreciated. Thanks in Advance

• One thing that you should consider is that A may be a Knight or a Knave but it cannot be both. The same applies for B. That is, try to implement an XOR operation. That is, XOR(AKnight,AKNave) and XOR(BKnight,BKNave) The XOR will be False if both are True. The XOR operation is not supported by this software but you can use And, Or and negation to implement it. – andreSmol Jul 9 '20 at 9:06