diff options
author | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-03-11 21:58:10 +0100 |
---|---|---|
committer | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-03-11 21:58:10 +0100 |
commit | db15c60df2cbc9c310422e1ce0fd4409acc4ce01 (patch) | |
tree | ae95275121b8ce1db6531c324e121b2b2611be17 /prolog/problems/lists/memb_2 | |
parent | 8a9f429b6c126e00af8d5f2650d6c4d705917b6a (diff) |
Hints for conc/3 added. And some misc bits here & there.
Diffstat (limited to 'prolog/problems/lists/memb_2')
-rw-r--r-- | prolog/problems/lists/memb_2/common.py | 8 | ||||
-rw-r--r-- | prolog/problems/lists/memb_2/sl.py | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/prolog/problems/lists/memb_2/common.py b/prolog/problems/lists/memb_2/common.py index c45168d..119363a 100644 --- a/prolog/problems/lists/memb_2/common.py +++ b/prolog/problems/lists/memb_2/common.py @@ -23,6 +23,7 @@ hint_type = { 'eq_instead_of_equ': Hint('eq_instead_of_equ'), 'predicate_always_false': Hint('predicate_always_false'), 'base_case': Hint('base_case'), + 'recursive_case': Hint('recursive_case'), 'timeout': Hint('timeout'), 'final_hint': Hint('final_hint'), } @@ -77,9 +78,14 @@ def hint(code, aux_code): return [{'id': 'base_case'}] # target predicate seems to always be false - if not prolog.engine.ask_truth(engine_id, 'memb(_, [_,_,_,_,_,_])'): + if not prolog.engine.ask_truthTO(engine_id, 'memb(_, [_,_,_,_,_,_])'): return [{'id': 'predicate_always_false'}] + # 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, 'memb(qQ, [qa,qb,qQ,qc])'): + return [{'id': 'recursive_case'}] + # TODO: Tim, can we include 'fail'-used as a general hint? except socket.timeout as ex: diff --git a/prolog/problems/lists/memb_2/sl.py b/prolog/problems/lists/memb_2/sl.py index c1b0a47..b133fdb 100644 --- a/prolog/problems/lists/memb_2/sl.py +++ b/prolog/problems/lists/memb_2/sl.py @@ -44,6 +44,10 @@ implicitno že kar v argumentih predikata (glavi stavka).</p> Do katerega elementa najlažje prideš?</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, |