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 ++++++++++++++++++++++- prolog/problems/family_relations/ancestor_2/sl.py | 4 +- 2 files changed, 85 insertions(+), 5 deletions(-) (limited to 'prolog') 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 = {} diff --git a/prolog/problems/family_relations/ancestor_2/sl.py b/prolog/problems/family_relations/ancestor_2/sl.py index 5d05696..e75db5b 100644 --- a/prolog/problems/family_relations/ancestor_2/sl.py +++ b/prolog/problems/family_relations/ancestor_2/sl.py @@ -3,7 +3,7 @@ slug = 'X je prednik od Y' description = '''\

ancestor(X, Y): X je prednik (oče, mama, babica, -pradedek, …) od Y.

+pradedek, ...) od Y.

 ?- ancestor(patricia, Y).
   Y = john ;
   Y = michael ;
@@ -79,7 +79,7 @@ npr. prababica ali prapradedek sta tudi prednika.

''', 'predicate_always_false': '''\ -

Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?

+

Vse kaže, da tvoj predikat vedno vrne "false". Si mu dal pravilno ime, si se morda pri imenu zatipkal?

Č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?

Možno je seveda tudi, da so tvoji pogoji prestrogi ali celo nemogoči (kot bi bila npr. zahteva, -- cgit v1.2.1