summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prolog/problems/lists_advanced/palindrome_1/en.py3
-rw-r--r--prolog/problems/lists_advanced/sublist_2/en.py53
-rw-r--r--prolog/problems/lists_advanced/sublist_2/sl.py4
3 files changed, 55 insertions, 5 deletions
diff --git a/prolog/problems/lists_advanced/palindrome_1/en.py b/prolog/problems/lists_advanced/palindrome_1/en.py
index 27103d3..8471ae2 100644
--- a/prolog/problems/lists_advanced/palindrome_1/en.py
+++ b/prolog/problems/lists_advanced/palindrome_1/en.py
@@ -13,7 +13,8 @@ description = '''\
</pre>'''
plan = ['''\
-<p>A palindrome is a list (ok, a word) that reads the same from front or back. Like aibohphobia. ;)</p>
+<p>A palindrome is a list (ok, a word) that reads the same from front or back. Like aibohphobia!
+Was it a car or a cat I saw? ;)</p>
''', '''\
<p>As always we want to reduce the problem into a smaller one. Let's chop off the first and the last element
of a list, and, if equal, proceed recursively.</p>
diff --git a/prolog/problems/lists_advanced/sublist_2/en.py b/prolog/problems/lists_advanced/sublist_2/en.py
index 67b50a4..33e59c5 100644
--- a/prolog/problems/lists_advanced/sublist_2/en.py
+++ b/prolog/problems/lists_advanced/sublist_2/en.py
@@ -2,7 +2,7 @@ name = 'sublist/2'
slug = 'generate sublists of a list'
description = '''\
-<p><code>sublist(L, SL)</code>: <code>SL</code> is a continuous sublist of the
+<p><code>sublist(L, SL)</code>: <code>SL</code> is a continuous sublist of
list <code>L</code>. Your program should return every possible sublist; each
answer may be returned more than once.</p>
<pre>
@@ -16,4 +16,53 @@ answer may be returned more than once.</p>
X = [3].
</pre>'''
-hint = {}
+plan = ['''\
+<p>First a reminder: we're looking for sublists, not subsets. The difference is that sublists contain a number of
+<em>consecutive</em> elements of the original list.</p>
+<p>Perhaps you should look for some pattern? And which predicate is ideal to search for patterns?
+You already know that. ;)</p>
+''', '''\
+<p>Of course, predicate <code>conc/3</code> can be used to search for patterns in lists. Perhaps this time
+we don't even need explicite recursion? Is that really possible in prolog? ;)</p>
+''', '''\
+<p>So, what could the pattern be? Well, a part of the original list! Imagine that the original list is a tube
+that you want to shorten -- a little bit from the left, a little bit from the right -- what's left is a sublist!
+You chop off some elements from the front of the original list, and then you chop off some from the end.</p>
+''']
+
+hint = {
+ 'eq_instead_of_equ': '''\
+<p>The operator <code>==</code> is "stricter" than operator <code>=</code> in the sense that
+for the latter it is enough to be able to make the two operands equal (unification). Perhaps by using <code>=</code>
+you can make the predicate <code>sublist/2</code> more general (e.g. able to work with output arguments becoming inputs).</p>
+<p>Of course, you can also solve the exercise without explicit use of either of these two operators, just
+remember that unification is implicitly performed with the predicate's arguments (head of clause).</p>
+''',
+
+ 'eq_instead_of_equ_markup': '''\
+<p>Perhaps the operator for unification (=) would be better?</p>
+''',
+
+ 'base_case': '''\
+<p>Did you think of a base case?</p>
+''',
+
+ 'recursive_case': '''\
+<p>The base case is ok. However, what about the general recursive case?</p>
+''',
+
+ 'predicate_always_false': '''\
+<p>It seems your predicate is <emph>always</emph> "false". Did you give it the correct name,
+or is it perhaps misspelled?</p>
+<p>If the name is correct, check whether something else is misspelled, perhaps there is a full stop instead of
+a comma or vice versa, or maybe you typed a variable name in lowercase?</p>
+<p>It is, of course, also possible that your conditions are too restrictive, or even impossible to satisfy
+(as would be, for example, the condition that <code>N</code> is equal to <code>N + 1</code>,
+or something similarly impossible).</p>
+''',
+
+ 'timeout': '''\
+<p>Is there an infinite recursion at work here? How will it ever stop?</p>
+<p>Or perhaps is there a missing, faulty, or simply incompatible (with the general recursive case) base case?</p>
+''',
+}
diff --git a/prolog/problems/lists_advanced/sublist_2/sl.py b/prolog/problems/lists_advanced/sublist_2/sl.py
index 4884665..b75aa0c 100644
--- a/prolog/problems/lists_advanced/sublist_2/sl.py
+++ b/prolog/problems/lists_advanced/sublist_2/sl.py
@@ -33,7 +33,7 @@ hint = {
'eq_instead_of_equ': '''\
<p>Operator <code>==</code> je strožji od operatorja <code>=</code> v smislu, da je za slednjega dovolj,
da elementa lahko naredi enaka (unifikacija). Morda z uporabo <code>=</code> narediš predikat
-<code>memb/2</code> delujoč tudi v kakšni drugi smeri.</p>
+<code>sublist/2</code> delujoč tudi v kakšni drugi smeri.</p>
<p>Seveda pa lahko nalogo rešiš brez obeh omenjenih operatorjev, spomni se, da lahko unifikacijo narediš
implicitno že kar v argumentih predikata (glavi stavka).</p>
''',
@@ -56,7 +56,7 @@ Do katerega elementa najlažje prideš?</p>
<p>Če je ime pravilno, se morda splača preveriti tudi, če se nisi zatipkal kje drugje,
je morda kakšna pika namesto vejice ali obratno, morda kakšna spremenljivka z malo začetnico?</p>
<p>Možno je seveda tudi, da so tvoji pogoji prestrogi ali celo nemogoči (kot bi bila npr. zahteva,
-da je <code>X</code> hkrati starš in sestra od <code>Y</code> ali kaj podobno zlobnega).</p>
+da je <code>N</code> enako kot <code>N + 1</code> ali kaj podobno logično zlobnega).</p>
''',
'timeout': '''\