summaryrefslogtreecommitdiff
path: root/prolog/problems/lists_advanced
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-08-10 00:18:27 +0200
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2016-08-10 00:18:27 +0200
commitc2e782122d52acea0e69f8a5a92b40bbbb7072e5 (patch)
treec32cb856f76c61080dd9acb2bb2b6847ffd1d97c /prolog/problems/lists_advanced
parentefc1dd926c83a0e772ccc87ffcf03218cbd90ed0 (diff)
English translation for rev/2 added.
Diffstat (limited to 'prolog/problems/lists_advanced')
-rw-r--r--prolog/problems/lists_advanced/rev_2/en.py79
-rw-r--r--prolog/problems/lists_advanced/rev_2/sl.py2
2 files changed, 43 insertions, 38 deletions
diff --git a/prolog/problems/lists_advanced/rev_2/en.py b/prolog/problems/lists_advanced/rev_2/en.py
index 01ed83e..3b85a74 100644
--- a/prolog/problems/lists_advanced/rev_2/en.py
+++ b/prolog/problems/lists_advanced/rev_2/en.py
@@ -11,84 +11,89 @@ description = '''\
</pre>'''
plan = ['''\
-<p>To je ena najlepših in najbolj poučnih nalog. Klasična rekurzija! Problem poskusi zmanjšati. Seveda, prevedi na
-krajši seznam.</p>
+<p>This is one of the most rewarding exercises. Classic recursion! Try to reduce the problem into a smaller one.
+That, of course, means reducing it to a shorter list.</p>
''', '''\
-<p>Seznamu odvzamem glavo, rekurzija mi obrne rep in vse, kar moram na koncu narediti jaz je, da glavo vstavim nazaj
-v obrnjen rep na pravo mesto.</p>
+<p>I divide the list into its head and tail, the recursion reverses the tail, and all I have to do
+is to insert the head into its proper location in the reversed tail.</p>
''', '''\
-<p>Če je podani seznam <code>L</code> sestavljen iz glave <code>H</code> in repa <code>T</code>
-in če predpostavim, da rekurzija obrne <code>T</code> v obrnjen rep <code>RT</code> in če <code>RT</code> na konec
-dodam <code>H</code>, potem je rezultat obrnjen seznam <code>L</code>.</p>
+<p>If the given list <code>L</code> is composed of head <code>H</code> and tail <code>T</code>
+and if I assume the recursion reverses tail <code>T</code> into reversed tail <code>RT</code> and if I add head
+<code>H</code> at the end of <code>RT</code>, then the result is reversed list <code>L</code>.</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>
-<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>
+<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 two elements equal (unification). Perhaps by using <code>=</code>
+you can make the predicate <code>rev/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>Morda bi bil bolj primeren operator za unifikacijo (=)?</p>
+<p>Perhaps the operator for unification (=) would be better?</p>
''',
'base_case': '''\
-<p>Si pomislil na robni pogoj? Kateri seznam je trivialno obrniti?</p>
+<p>Did you think of a base case? Which list is the most trivial to reverse?</p>
''',
'recursive_case': '''\
-<p>Robni primer deluje. Kaj pa rekurzivni, splošni, primer?</p>
+<p>The base case is ok. However, what about the general recursive case?</p>
''',
'predicate_always_false': '''\
-<p>Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?</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>N</code> enako kot <code>N + 1</code> ali kaj podobno logično zlobnega).</p>
+<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>Je morda na delu potencialno neskončna rekurzija? Kako se bo ustavila?</p>
-<p>Morda pa je kriv tudi manjkajoč, neustrezen ali preprosto nekompatibilen (s splošnim primerom) robni pogoj?</p>
+<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>
''',
'base_case_at_len1': '''\
-<p>Ta robni pogoj je seveda povsem smiseln, a ga vseeno popravi tako, da bo deloval tudi za prazen seznam.
-Vendar ne imej dveh robnih pogojev, ker bo to podvajalo rešitve./p>
+<p>Your base case is perfectly reasonable, but it doesn't work for an empty list.
+However, don't use two base cases here, because this will duplicate the solutions./p>
''',
'arbitrary_base_case': '''\
-<p>Kaj je rezultat obračanja praznega seznama? Gotovo ne karkoli (spremenljivka brez določene vrednosti)!</p>
+<p>What is the result of reversing an empty list? Surely not an arbitrary list (a variable without
+an assigned value)!</p>
''',
'forcing_result_onto_recursion': '''
-<p>Ne vsiljuj rekurziji kaj naj vrne, prepusti se ji. To je tisti del, ko narediš predpostavko,
-če je ta izpolnjena, potem bo tvoje pravilo delovalo za večji primer.</p>
-<p>Je tvoj rekurzivni klic oblike <code>rev(T, [RevTail|H])</code>? S tem vsiljuješ rekurziji
-da mora <emph>vrniti</emph> na zadnjem mestu tudi glavo, ki je sploh ne pozna, ker si jo ravnokar vzel stran! To moraš
-narediti ti z rezultatom, ki ti ga rekurzija vrne. Skratka, element <code>H</code> vstavi izven rekurzivnega klica.</p>
+<p>Don't force the result onto recursion, don't tell it what it should return. Just assume it will do its job.
+If this assumption is correct, then the rule will work for a larger case.</p>
+<p>Is your recursive call of the form <code>rev(T, [RevTail|H])</code>? This forces the recursive call to
+<emph>return</emph> the head at the end of the list. But it doesn't know of this head, because you just
+took it away! Inserting the head into the result, returned by the recursive call, is your job. To put it shortly,
+insert <code>H</code> outside of the recursive call.</p>
''',
'using_other_solutions': '''\
-<p>Od predikatov <code>last/2</code>, <code>shiftleft/2</code> ali <code>shiftright/2</code> tukaj ne bo veliko
-pomoči. Poskusi raje brez, bo lažje.</p>
+<p>Predicates <code>last/2</code>, <code>shiftleft/2</code>, or <code>shiftright/2</code> will not be of
+much help here. Rather try without them, it will be easier.</p>
''',
'insertion_at_beginning': '''\
-<p>Vstavljaš morda glavo nazaj <em>na začetek</em> obrnjenega repa? To ni pravo mesto, ker s tem samo sestaviš nazaj
-enak seznam kot na začetku.</p>
+<p>Did you insert the head at <em>the start</em> of the reversed tail? That's not its proper place; in this way
+you just reassemble the original list.</p>
''',
'invalid_insert_at_end': '''\
-<p>Spomni se, rep seznama je vedno seznam! Kako vstaviš element na zadnje mesto?</p>
+<p>Remember, a list's tail is always another list, not an element.
+How do you insert an element at the end of the list?</p>
''',
'conc_arg_not_list': '''\
-<p>Vsi trije argumenti predikata <code>conc/3</code> morajo biti <em>seznami</em>. Si prepričan,
-da si ga tako uporabil?</p>
+<p>All three arguments of predicate <code>conc/3</code> are <em>lists</em>.
+Are you sure you used it properly?</p>
''',
}
diff --git a/prolog/problems/lists_advanced/rev_2/sl.py b/prolog/problems/lists_advanced/rev_2/sl.py
index 5c8ab13..cc7bd89 100644
--- a/prolog/problems/lists_advanced/rev_2/sl.py
+++ b/prolog/problems/lists_advanced/rev_2/sl.py
@@ -26,7 +26,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>rev/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>
''',