From 3058111ccb4ee97f061a8407335c29fcaa386b18 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 8 Aug 2016 20:59:14 +0200 Subject: English translation for ancestor/2 added. --- prolog/problems/family_relations/ancestor_2/en.py | 86 ++++++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) (limited to 'prolog/problems/family_relations/ancestor_2/en.py') diff --git a/prolog/problems/family_relations/ancestor_2/en.py b/prolog/problems/family_relations/ancestor_2/en.py index 5ae1bd0..cec2a29 100644 --- a/prolog/problems/family_relations/ancestor_2/en.py +++ b/prolog/problems/family_relations/ancestor_2/en.py @@ -2,12 +2,92 @@ name = 'ancestor/2' slug = 'the ancestor relation' description = '''\ -

ancestor(X, Y): X is an ancestor (parent, grandparent, …) of Y.

+

ancestor(X, Y): X is an ancestor (parent, grandparent, grandgrandparent, ...) of Y.

 ?- ancestor(patricia, X).
   X = john ;
   X = michael ;
   X = michelle.
-
''' + +

Family trees are +described with predicates parent/2, male/1, and +female/1.

+''' + +plan = ['''\ +

It's time to use recursion for the first time... how can we transpose the problem to a smaller one (a single step smaller that is)?

+

A parent of someone, who is a parent of Y, is also an ancestor of Y.

+''', '''\ +

If X is a parent of some Z and that Z is an ancestor of Y, +then X is also an ancestor of Y.

+''', '''\ +

If X is a parent of Z, and Z is an ancestor of Y, then X is also an ancestor of Y.

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

Is gender really important?

+''', + + 'gender_is_irrelevant_markup': '''\ +

Is this necessary?

+''', + + 'grandparent_used': '''\ +

The solution using the grandparent relation will not be general enough, try using recursion instead. +Try to transpose the problem into a "smaller" one, e.g. an ancestor in one step less (a closer ancestor).

+''', + + 'grandparent_used_markup': '''\ +

Can you solve without using this?

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

Did you think of a base case? The recursion has to stop at some point. +What is the most obvious pair (ancestor, descendand)?

+

+''', # TODO: morda ta hint naredim z "more": najprej tekst, ob kliku pa še slika... (sicer je preveč očitno) + + 'ancestor_to_oneself': '''\ +

How can anyone be an ancestor to him- or herself? This can be inferred from the current version of the program. +It might also help to graphically sketch your current solution.

+''', + + 'ancestor_to_oneself_with_or': '''\ +

How can anyone be an ancestor to him- or herself? This can be inferred from the current version of the program. +It might help to graphically sketch your current solution.

+

Perhaps you should also check your use of the semicolon. The semicolon basically creates two separate clauses or +branches (one or the other can hold, or even both). However, be careful, as this two branches are independent of +one another -- assigned values to variables in one branch do not transfer to the other branch.

+''', + + 'only_two_levels_deep': '''\ +

Your solution is not general enough. An ancestor can also be someone "more steps away" than grandparents, +e.g. grandgrandparents or grandgrandgrandparents are also ancestors.

+''', + + 'descendant_need_not_be_parent': '''\ +

The descendant Y doesn't actually need to have any children...

+''', + + 'wrong_direction': '''\ +

Did you perhaps program exactly the reverse relation, descendant instead of ancestor? +X should be an ancestor of Y and not the other way around!

+

+''', + + '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 X is both parent and a sister of Y, or +something similar).

+''', + + '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?

+''', +} -hint = {} -- cgit v1.2.1