summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-09-08 19:09:21 +0200
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-09-08 19:09:21 +0200
commit29a65937bab5416adc060b9bf60652cff91276c0 (patch)
treee52ddf9f408bad73b7867b032c87b76213f10a4b
parent4a01e895b521c75406270abd581cd3fbb09f2c08 (diff)
English translations for evenlen/1 and oddlen/1 added.
-rw-r--r--prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/en.py71
-rw-r--r--prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/sl.py7
2 files changed, 73 insertions, 5 deletions
diff --git a/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/en.py b/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/en.py
index 7e7a7d3..601488a 100644
--- a/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/en.py
+++ b/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/en.py
@@ -1,9 +1,10 @@
name = 'evenlen/1 + oddlen/1'
-slug = 'check if the length of a list is even or odd'
+slug = 'check if the length of a list is even or odd (without arithmetics)'
description = '''\
<p><code>evenlen(L)</code>: the list <code>L</code> has an even number of elements.<br />
<code>oddlen(L)</code>: the list <code>L</code> has an odd number of elements.</p>
+<p>Don't use arithmetic operations with this exercise, it destroys the point of it!</p>
<pre>
?- oddlen([1,2,3,4,5]).
true.
@@ -13,4 +14,70 @@ description = '''\
true.
</pre>'''
-hint = {}
+plan = ['''\
+<p>You can solve this exercise as two separate, albeit similar, ones, or as a single exercise that
+intertwines two predicates. The second option is probably more interesting.</p>
+''', '''\
+<p>Intertwining in this case means that one predicate calls the other and vice versa. Even. Odd. Even. Odd.</p>
+''', '''\
+<p>If the tail (list without a single head) is of <em>even</em> length, then the whole list is of
+<em>odd</em> length. And vice versa.</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 predicates <code>oddlen/1</code> and <code>evenlen/1</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? What's the simplest case that you can trivially solve?</p>
+''',
+
+ 'extra_base_case': '''\
+<p>You're getting duplicate solutions. It's enough to only have a single base case for this pair of
+predicates; you don't need one for <code>evenlen/1</code> and one for <code>oddlen/1</code>.</p>
+''',
+
+ 'arbitrary_base_case': '''\
+<p>It seems that you accept an arbitrary result (a variable without an assigned value). This will not be ok.</p>
+<p>Note that <code>_</code> is not the same as <code>[_]</code>. The first pattern represents an arbitrary
+variable (anything), the second a list with <em>a single</em> arbitrary element.</p>
+''',
+
+ 'arithmetics_used': '''\
+<p>Please don't use arithmetics to solve this exercise, not even for counting the length of the list.
+It can be solved without that and it's also a much nicer idea or two.</p>
+''',
+
+'odd_and_even_mixed_up': '''\
+<p>Did you mix up odd and even? Zero is even, one is odd, two is... ;)</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/evenlen_1_+_oddlen_1/sl.py b/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/sl.py
index 000ce1a..1c0b596 100644
--- a/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/sl.py
+++ b/prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/sl.py
@@ -4,6 +4,7 @@ slug = 'Brez aritmetike preveri, če je seznam sode ali lihe dolžine'
description = '''\
<p><code>evenlen(L)</code>: seznam <code>L</code> ima sodo število elementov.<br />
<code>oddlen(L)</code>: seznam <code>L</code> ima liho število elementov.</p>
+<p>Ne uporabljaj aritmetike pri tej nalogi, ker to uniči njeno poanto!</p>
<pre>
?- oddlen([1,2,3,4,5]).
true.
@@ -19,15 +20,15 @@ Druga verzija je verjetno bolj zanimiva.</p>
''', '''\
<p>Prepletanje tu pomeni, da ena naloga kliče drugo in obratno. Sodo. Liho. Sodo. Liho.</p>
''', '''\
-<p>Če je rep (seznam brez ene glave) <em>sode</em> dolžine, potem je celoten seznam </em>lihe</em> dolžine.
+<p>Če je rep (seznam brez ene glave) <em>sode</em> dolžine, potem je celoten seznam <em>lihe</em> dolžine.
In obratno.</p>
''']
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>
+da elementa lahko naredi enaka (unifikacija). Morda z uporabo <code>=</code> narediš predikata
+<code>oddlen/1</code> in <code>evenlen/1</code> delujoča 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>
''',