summaryrefslogtreecommitdiff
path: root/prolog/problems
diff options
context:
space:
mode:
Diffstat (limited to 'prolog/problems')
-rw-r--r--prolog/problems/lists/last_elem_2/common.py14
-rw-r--r--prolog/problems/lists/last_elem_2/sl.py5
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>
''',