From 29a65937bab5416adc060b9bf60652cff91276c0 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Thu, 8 Sep 2016 19:09:21 +0200 Subject: English translations for evenlen/1 and oddlen/1 added. --- .../lists_advanced/evenlen_1_+_oddlen_1/en.py | 71 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'prolog/problems/lists_advanced/evenlen_1_+_oddlen_1/en.py') 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 = '''\

evenlen(L): the list L has an even number of elements.
oddlen(L): the list L has an odd number of elements.

+

Don't use arithmetic operations with this exercise, it destroys the point of it!

 ?- oddlen([1,2,3,4,5]).
   true.
@@ -13,4 +14,70 @@ description = '''\
   true.
 
''' -hint = {} +plan = ['''\ +

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.

+''', '''\ +

Intertwining in this case means that one predicate calls the other and vice versa. Even. Odd. Even. Odd.

+''', '''\ +

If the tail (list without a single head) is of even length, then the whole list is of +odd length. And vice versa.

+'''] + +hint = { + 'eq_instead_of_equ': '''\ +

The operator == is "stricter" than operator = in the sense that +for the latter it is enough to be able to make the two operands equal (unification). Perhaps by using = +you can make the predicates oddlen/1 and evenlen/1 more general +(e.g. able to work with output arguments becoming inputs).

+

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).

+''', + + 'eq_instead_of_equ_markup': '''\ +

Perhaps the operator for unification (=) would be better?

+''', + + 'base_case': '''\ +

Did you think of a base case? What's the simplest case that you can trivially solve?

+''', + + 'extra_base_case': '''\ +

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 evenlen/1 and one for oddlen/1.

+''', + + 'arbitrary_base_case': '''\ +

It seems that you accept an arbitrary result (a variable without an assigned value). This will not be ok.

+

Note that _ is not the same as [_]. The first pattern represents an arbitrary +variable (anything), the second a list with a single arbitrary element.

+''', + + 'arithmetics_used': '''\ +

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.

+''', + +'odd_and_even_mixed_up': '''\ +

Did you mix up odd and even? Zero is even, one is odd, two is... ;)

+''', + + 'recursive_case': '''\ +

The base case is ok. However, what about the general recursive case?

+''', + + 'predicate_always_false': '''\ +

It seems your predicate is always "false". Did you give it the correct name, +or is it perhaps misspelled?

+

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?

+

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 N is equal to N + 1, +or something similarly impossible).

+''', + + 'timeout': '''\ +

Is there an infinite recursion at work here? How will it ever stop?

+

Or perhaps is there a missing, faulty, or simply incompatible (with the general recursive case) base case?

+''', +} -- cgit v1.2.1