diff options
author | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2015-09-30 17:39:14 +0200 |
---|---|---|
committer | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2015-09-30 17:39:14 +0200 |
commit | aec4e861a2477762326c0f9b001668f5c1ff9ddb (patch) | |
tree | 5a0ede5c683f2bc9fd7850bdfd4495ab2047a598 /prolog/problems/family_relations/grandparent_2 | |
parent | f08c7bfd6d3631d75083b8d14fb2c427be7b2a9d (diff) |
Figures added for mother problem.
Diffstat (limited to 'prolog/problems/family_relations/grandparent_2')
-rw-r--r-- | prolog/problems/family_relations/grandparent_2/common.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py index 98e40fc..8ccd23d 100644 --- a/prolog/problems/family_relations/grandparent_2/common.py +++ b/prolog/problems/family_relations/grandparent_2/common.py @@ -103,16 +103,21 @@ def hint(program, solved_problems): 'grandparent(X, _), \+ parent(X, _)'): return [{'id': 'x_must_be_parent'}] - # X does not necessarily need to have a parent - if prolog.engine.ask_one(engine_id, - 'grandparent(X, _), \+ parent(_, X)') == 'false': - return [{'id': 'x_need_not_have_parent'}] - # Y must have a parent if prolog.engine.ask_truth(engine_id, 'grandparent(_, Y), \+ parent(_, Y)'): return [{'id': 'y_must_have_parent'}] + # stop further hint testing if target predicate is always true or always false + if prolog.engine.ask_truth(engine_id, + '\+ grandparent(_, _) ; findall(X/Y, grandparent(X, Y), [A/B]), var(A), var(B)'): + return [] + + # X does not necessarily need to have a parent + if prolog.engine.ask_one(engine_id, + 'grandparent(X, _), \+ parent(_, X)') == 'false': + return [{'id': 'x_need_not_have_parent'}] + # Y does not necessarily need to be a parent if prolog.engine.ask_one(engine_id, 'grandparent(_, Y), \+ parent(Y, _)') == 'false': @@ -125,5 +130,5 @@ def hint(program, solved_problems): if engine_id: prolog.engine.destroy(engine_id) - return None + return [] |