I am new to prolog and I am trying to solve the following question. I am having difficulty trying to understand the logic to solve the problem. I know its similar to zebra problem but, I am unsure how to approach. Any help would be greatly appreciated.
The answers submitted by five students to a T/F quiz are as follows.
Teresa: T T F T F
Tim: F T T T F
Tania: T F T T F
Tom: F T T F T
Tony: T F T F T
- Tania got more answers right than Teresa did.
- Tom got more right than Tim.
- Tony did not get all the answers right, nor did he get them all wrong.
Write a Prolog program quiz(Answer)
that asserts Answer is the list of t
and f
constants that is the correct answer to the quiz..
answers(teresa, [t,t,f,t,f]).
, etc. You could create a predicate to generate possible correct answer sets and compute each person's score against it. Backtrack when the conditions for score comparisons don't match. There really is only one result. – lurker