summaryrefslogtreecommitdiff
path: root/prolog/problems/lists/del_3
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-03-09 19:48:21 +0100
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-03-09 19:48:21 +0100
commit913007d3f60d86c3f4e11733153233434da8607f (patch)
treec96af6319f24d7380d2e62865df8bc5345c9c473 /prolog/problems/lists/del_3
parent5ebd30ba1321ffba7a8c2070f18d7418727a6d5e (diff)
Hints for del/3 updated.
Diffstat (limited to 'prolog/problems/lists/del_3')
-rw-r--r--prolog/problems/lists/del_3/common.py6
-rw-r--r--prolog/problems/lists/del_3/sl.py4
2 files changed, 10 insertions, 0 deletions
diff --git a/prolog/problems/lists/del_3/common.py b/prolog/problems/lists/del_3/common.py
index f3dfcb2..c984fef 100644
--- a/prolog/problems/lists/del_3/common.py
+++ b/prolog/problems/lists/del_3/common.py
@@ -27,6 +27,7 @@ hint_type = {
'final_hint': Hint('final_hint'),
'del_from_empty_list_success': Hint('del_from_empty_list_success'),
'lost_heads': Hint('lost_heads'),
+ 'recursive_case': Hint('recursive_case'),
}
test_cases = [
@@ -97,6 +98,11 @@ def hint(code, aux_code):
# L=[H|T] at the end of the rule; this can be detected with test cases and can be wrong (in some sense)
# TODO: implement it, and provide a good explanation (might be hard)
+ # base case works, the recursive doesn't (but it doesn't timeout)
+ # this may be left as the last, most generic hint
+ if not prolog.engine.ask_truth(engine_id, 'del(qQ, [qa,qb,qQ,qc], [qa,qb,qc])'):
+ return [{'id': 'recursive_case'}]
+
except socket.timeout as ex:
return [{'id': 'timeout'}]
diff --git a/prolog/problems/lists/del_3/sl.py b/prolog/problems/lists/del_3/sl.py
index 5fa8e17..0875fe0 100644
--- a/prolog/problems/lists/del_3/sl.py
+++ b/prolog/problems/lists/del_3/sl.py
@@ -48,6 +48,10 @@ implicitno že kar v argumentih predikata (glavi stavka).</p>
<p>Si pomislil na robni pogoj? Kaj je najbolj enostaven primer, kateri element v seznamu najlažje zbrišeš?</p>
''',
+ 'recursive_case': '''\
+<p>Robni primer deluje. Kaj pa rekurzivni, splošni, primer?</p>
+''',
+
'predicate_always_false': '''\
<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</p>
<p>Če je ime pravilno, se morda splača preveriti tudi, če se nisi zatipkal kje drugje,