diff options
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, |