summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/descendant_2/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/family_relations/descendant_2/common.py')
-rw-r--r--prolog/problems/family_relations/descendant_2/common.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/prolog/problems/family_relations/descendant_2/common.py b/prolog/problems/family_relations/descendant_2/common.py
index 70936da..b4d8f31 100644
--- a/prolog/problems/family_relations/descendant_2/common.py
+++ b/prolog/problems/family_relations/descendant_2/common.py
@@ -88,6 +88,13 @@ def hint(code, aux_code):
return [{'id': 'grandparent_used_markup', 'start': m[0], 'end': m[1]} for m in marks] + \
[{'id': 'grandparent_used'}]
+ # ancestor instead of descendant (wrong direction)
+ # warning: knowledge base dependent
+ if prolog.engine.ask_truthTO(engine_id,
+ 'findall(_, descendant(william, X), L1), length(L1, 6), \
+ findall(_, descendant(X, william), L2), length(L2, 2)'):
+ return [{'id': 'wrong_direction'}]
+
# missing/failed base case
if prolog.engine.ask_truthTO(engine_id,
'parent(Y, X), \+ descendant(X, Y)'):
@@ -100,13 +107,6 @@ def hint(code, aux_code):
else:
return [{'id': 'descendant_of_oneself'}]
- # ancestor instead of descendant (wrong direction)
- # warning: knowledge base dependent
- if prolog.engine.ask_truthTO(engine_id,
- 'findall(_, descendant(william, X), L1), length(L1, 6), \
- findall(_, descendant(X, william), L2), length(L2, 2)'):
- return [{'id': 'wrong_direction'}]
-
# X does not necessarily need to be a parent
if prolog.engine.ask_one(engine_id,
'descendant(X, _), \+ parent(X, _)') == 'false':