From db15c60df2cbc9c310422e1ce0fd4409acc4ce01 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Fri, 11 Mar 2016 21:58:10 +0100 Subject: Hints for conc/3 added. And some misc bits here & there. --- prolog/problems/lists/memb_2/common.py | 8 +++++++- prolog/problems/lists/memb_2/sl.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'prolog/problems/lists/memb_2') 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 @@ -42,6 +42,10 @@ implicitno že kar v argumentih predikata (glavi stavka).

'base_case': '''\

Si pomislil na robni pogoj? Kaj je najbolj enostaven primer, ko je element v seznamu? Do katerega elementa najlažje prideš?

+''', + + 'recursive_case': '''\ +

Robni primer deluje. Kaj pa rekurzivni, splošni, primer?

''', 'predicate_always_false': '''\ -- cgit v1.2.1