diff options
author | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-03-14 04:06:03 +0100 |
---|---|---|
committer | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-03-14 04:06:03 +0100 |
commit | 71772851de61a77598bd5ffc2e729a82d5da6416 (patch) | |
tree | 2f5efe9f31dfd61b32f3fb76b75ea6e03412894d /prolog/problems/lists | |
parent | a4e8456ab5f14a34cb2f79c0946c439a976041f8 (diff) |
Hints for last_elem/2 updated.
Diffstat (limited to 'prolog/problems/lists')
-rw-r--r-- | prolog/problems/lists/last_elem_2/common.py | 14 | ||||
-rw-r--r-- | prolog/problems/lists/last_elem_2/sl.py | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/prolog/problems/lists/last_elem_2/common.py b/prolog/problems/lists/last_elem_2/common.py index 75cec75..9c44231 100644 --- a/prolog/problems/lists/last_elem_2/common.py +++ b/prolog/problems/lists/last_elem_2/common.py @@ -29,6 +29,7 @@ hint_type = { '[]_should_not_succeed': Hint('[]_should_not_succeed'), 'list_returned': Hint('list_returned'), 'clumsy_conc_use': Hint('clumsy_conc_use'), + 'unsuccessful_conc_use': Hint('unsuccessful_conc_use'), } test_cases = [ @@ -77,15 +78,20 @@ def hint(code, aux_code): # recursion is getting bigger and bigger - # succeeds when asked to return the last element of an empty list - if prolog.engine.ask_truthTO(engine_id, 'last_elem([], _)'): - return [{'id': '[]_should_not_succeed'}] - # using conc, but clumsily: conc(_, X, L) instead of conc(_, [X], L) if prolog.util.Token('NAME', 'conc') in tokens and \ prolog.engine.ask_truthTO(engine_id, 'last_elem([q,a,b,c], [q,a,b,c])'): return [{'id': 'clumsy_conc_use'}] + # general unsuccessful use of conc, but not specifically detected + # return general_conc hint, not to confuse/force the student into a non-conc solution + if prolog.util.Token('NAME', 'conc') in tokens: + return [{'id': 'unsuccessful_conc_use'}] + + # succeeds when asked to return the last element of an empty list + if prolog.engine.ask_truthTO(engine_id, 'last_elem([], _)'): + return [{'id': '[]_should_not_succeed'}] + # returns a list, not an element as required if prolog.engine.ask_truthTO(engine_id, 'last_elem([q], X), is_list(X)'): return [{'id': 'list_returned'}] diff --git a/prolog/problems/lists/last_elem_2/sl.py b/prolog/problems/lists/last_elem_2/sl.py index bcc33f8..7ab8ddc 100644 --- a/prolog/problems/lists/last_elem_2/sl.py +++ b/prolog/problems/lists/last_elem_2/sl.py @@ -51,6 +51,11 @@ implicitno že kar v argumentih predikata (glavi stavka).</p> biti dolžine ena, če hočeš doseči to kar želiš. Torej vzorec oblike <code>[X]</code>, kajne?</p> ''', + 'unsuccessful_conc_use': '''\ +<p>Uporabljaš <code>conc/3</code>? Zanimiva ideja, da se rešiti tudi tako. Vendar boš moral še malo premisliti. +Ne pozabi, <code>conc/3</code> ima tri argumente, vsi so seznami. Premisli, kakšen vzorec potrebuješ...</p> +''', + 'recursive_case': '''\ <p>Robni primer deluje. Kaj pa rekurzivni, splošni, primer?</p> ''', |