Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.
Anthony must be a student, and his two choices are facts with choice1 and choice2.
22 student(anthony). 23 choice1(anthony, history). 24 choice2(anthony, geography).
Clause 22 student(anthony) correct [1]
Clause 23 choice1(anthony, history) correct [1]
Clause 24 choice2(anthony, geography) correct [1]
Look for every choice1 fact with mathematics: clauses 15, 17 and 18.
Write: X = tomaz, pietre, nico [1]
The rule needs N to be a student, S to be a subject and N not to have S as first choice.
may_choose_subject(N, S) IF student(N) AND subject(S) AND NOT choice1(N, S)
student(N) [1]
subject(S) [1]
NOT choice1(N, S) [1]
All operators (AND or commas) correct, with no extra code [1]
Commas may be used instead of AND, and the terms can be in a different order.
▶ Topic lesson
A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.