summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/father_2/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/family_relations/father_2/common.py')
-rw-r--r--prolog/problems/family_relations/father_2/common.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/prolog/problems/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py
index cbfbcab..1643066 100644
--- a/prolog/problems/family_relations/father_2/common.py
+++ b/prolog/problems/family_relations/father_2/common.py
@@ -21,6 +21,7 @@ father(X, Y) :-
hint_type = {
'or_instead_of_and': Hint('or_instead_of_and'),
+ 'or_instead_of_and_two_rules': Hint('or_instead_of_and_two_rules'),
'x_must_be_male': Hint('x_must_be_male'),
'x_must_be_parent': Hint('x_must_be_parent'),
'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'),
@@ -80,6 +81,12 @@ def hint(program, solved_problems):
'findall(_, father(X, Y), L), length(L, 48)'):
return [{'id': 'or_instead_of_and'}]
+ # OR instead of AND written with two rules, namely:
+ # (r1) father(X, Y):- male(X). (r2) father(X, Y):- parent(X, Y).
+ if prolog.engine.ask_truth(engine_id,
+ 'findall(_, father(X, Y), L), length(L, 48)'):
+ return [{'id': 'or_instead_of_and_two_rules'}]
+
# X must be male
if prolog.engine.ask_truth(engine_id, 'female(X), father(X, _)'):
return [{'id': 'x_must_be_male'}]