summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/grandparent_2
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-02-29 00:38:16 +0100
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-02-29 00:38:16 +0100
commit73b899272899bc30f92e0032f96cc3f40c7925a7 (patch)
tree8a4428a1ea828e248575e506236e78060753526a /prolog/problems/family_relations/grandparent_2
parent90dbc3fa624d62e093bea7b90a72a28ad216f7bd (diff)
Additional improvements to hints for mother, father, grandparent, sister, and brother problems.
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