summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/grandparent_2
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems/family_relations/grandparent_2')
-rw-r--r--prolog/problems/family_relations/grandparent_2/common.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py
index 431071e..1cfdfe8 100644
--- a/prolog/problems/family_relations/grandparent_2/common.py
+++ b/prolog/problems/family_relations/grandparent_2/common.py
@@ -71,6 +71,15 @@ def hint(code, aux_code):
# TODO: generic hint for:
# TODO: parent(X, Z1), parent(Z2, Y), Z1 = Z2
+ # gender testing is redundant
+ # this is not necessarily wrong, but worth mentioning anyway
+ targets = [prolog.util.Token('NAME', 'male'), prolog.util.Token('NAME', 'female'),
+ prolog.util.Token('NAME', 'mother'), prolog.util.Token('NAME', 'father')]
+ marks = [(t.pos, t.pos + len(t.val)) for t in tokens if t in targets]
+ if marks:
+ return [{'id': 'gender_is_irrelevant_markup', 'start': m[0], 'end': m[1]} for m in marks] + \
+ [{'id': 'gender_is_irrelevant'}]
+
# target predicate seems to always be false
if not prolog.engine.ask_truth(engine_id, 'grandparent(_, _)'):
return [{'id': 'predicate_always_false'}]
@@ -82,15 +91,6 @@ def hint(code, aux_code):
'findall(_, grandparent(X, Y), L), length(L, 1024)'):
return [{'id': 'no_common_z'}]
- # gender testing is redundant
- # this is not necessarily wrong, but worth mentioning anyway
- targets = [prolog.util.Token('NAME', 'male'), prolog.util.Token('NAME', 'female'),
- prolog.util.Token('NAME', 'mother'), prolog.util.Token('NAME', 'father')]
- marks = [(t.pos, t.pos + len(t.val)) for t in tokens if t in targets]
- if marks:
- return [{'id': 'gender_is_irrelevant_markup', 'start': m[0], 'end': m[1]} for m in marks] + \
- [{'id': 'gender_is_irrelevant'}]
-
# OR (;) instead of AND (,)
# this hint has to be before the next two
# as otherwise those two would always override it