summaryrefslogtreecommitdiff
path: root/prolog/problems/lists_advanced/shiftleft_2
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-20 10:18:12 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-03-20 10:18:12 +0100
commitab723135fc32ac8dee6ce1c18f1e303955425df7 (patch)
treed00e80e67203983b6580cbd6d7144189b77d840a /prolog/problems/lists_advanced/shiftleft_2
parent1a602429e86680d82a5ab8064386e66a1126cf36 (diff)
Prolog: add triggers for shiftleft hints
Diffstat (limited to 'prolog/problems/lists_advanced/shiftleft_2')
-rw-r--r--prolog/problems/lists_advanced/shiftleft_2/common.py18
-rw-r--r--prolog/problems/lists_advanced/shiftleft_2/sl.py12
2 files changed, 30 insertions, 0 deletions
diff --git a/prolog/problems/lists_advanced/shiftleft_2/common.py b/prolog/problems/lists_advanced/shiftleft_2/common.py
index 77b66ca..2225bdd 100644
--- a/prolog/problems/lists_advanced/shiftleft_2/common.py
+++ b/prolog/problems/lists_advanced/shiftleft_2/common.py
@@ -23,6 +23,9 @@ hint_type = {
'eq_instead_of_equ': Hint('eq_instead_of_equ'),
'predicate_always_false': Hint('predicate_always_false'),
'timeout': Hint('timeout'),
+ 'conc_arg_not_list': Hint('conc_arg_not_list'),
+ 'arbitrary_result': Hint('arbitrary_result'),
+ 'tail_must_be_list': Hint('tail_must_be_list'),
}
test_cases = [
@@ -67,6 +70,21 @@ def hint(code, aux_code):
return [{'id': 'eq_instead_of_equ_markup', 'start': m[0], 'end': m[1]} for m in marks] + \
[{'id': 'eq_instead_of_equ'}]
+ # arbitrary result
+ if prolog.engine.ask_truthTO(engine_id,
+ 'shiftleft([27, 81, 243], granddad(Q, q))'):
+ return [{'id': 'arbitrary_result'}]
+
+ # conc/3 argument not a list
+ if prolog.engine.ask_truthTO(engine_id,
+ 'shiftleft([9, 3, 1, 27, 81, 243], [3, 1, 27, 81, 243 | 9])'):
+ return [{'id': 'conc_arg_not_list'}]
+
+ # tail must be list
+ if prolog.engine.ask_truthTO(engine_id,
+ 'shiftleft([27, 9, 3, 1, 81, 243], [[9, 3, 1, 81, 243] | 27])'):
+ return [{'id': 'tail_must_be_list'}]
+
# target predicate seems to always be false
if not prolog.engine.ask_truthTO(engine_id, 'shiftleft(_, _)'):
return [{'id': 'predicate_always_false'}]
diff --git a/prolog/problems/lists_advanced/shiftleft_2/sl.py b/prolog/problems/lists_advanced/shiftleft_2/sl.py
index fc41e3c..ec55c4e 100644
--- a/prolog/problems/lists_advanced/shiftleft_2/sl.py
+++ b/prolog/problems/lists_advanced/shiftleft_2/sl.py
@@ -33,4 +33,16 @@ da je <code>X</code> hkrati starš in sestra od <code>Y</code> ali kaj podobno z
<p>Je morda na delu potencialno neskončna rekurzija? Kako se bo ustavila?</p>
<p>Morda pa je kriv tudi manjkajoč, neustrezen ali preprosto nekompatibilen (s splošnim primerom) robni pogoj?</p>
''',
+
+ 'conc_arg_not_list': '''\
+<p>conc_arg_not_list</p>
+''',
+
+ 'arbitrary_result': '''\
+<p>arbitrary_result</p>
+''',
+
+ 'tail_must_be_list': '''\
+<p>tail_must_be_list</p>
+''',
}