diff options
author | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-02-28 22:14:02 +0100 |
---|---|---|
committer | Aleksander Sadikov <aleksander.sadikov@fri.uni-lj.si> | 2016-02-28 22:14:02 +0100 |
commit | bc40d810afbcde332730d50ed490deb432689db1 (patch) | |
tree | ef9dae0e3e67af9c8b1013d5406b87550b326b47 /prolog/problems/family_relations/brother_2 | |
parent | 74022caadc0b526c8f4224786a98aa7504ab035f (diff) |
sister/2 and brother/2 hints improved.
Diffstat (limited to 'prolog/problems/family_relations/brother_2')
-rw-r--r-- | prolog/problems/family_relations/brother_2/common.py | 9 | ||||
-rw-r--r-- | prolog/problems/family_relations/brother_2/sl.py | 6 |
2 files changed, 13 insertions, 2 deletions
diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py index c49489e..7f61744 100644 --- a/prolog/problems/family_relations/brother_2/common.py +++ b/prolog/problems/family_relations/brother_2/common.py @@ -26,6 +26,7 @@ hint_type = { 'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'), 'x_y_must_be_different': Hint('x_y_must_be_different'), 'neq_used_too_early': Hint('neq_used_too_early'), + 'nm_instead_of_neq': Hint('nm_instead_of_neq'), } test_cases = [ @@ -73,10 +74,14 @@ def hint(code, aux_code): return [{'id': 'common_parent_needed'}] # Y can be of any gender, incl. female - if prolog.engine.ask_one(engine_id, - 'brother(_, Y), female(Y)') == 'false': + if prolog.engine.ask_truth(engine_id, 'brother(_, Y)') and \ + prolog.engine.ask_one(engine_id, 'brother(_, Y), female(Y)') == 'false': return [{'id': 'y_can_be_of_any_gender'}] + # use of \= instead of \== + if prolog.util.Token('NEQ', '\=') in tokens: + return [{'id': 'nm_instead_of_neq'}] + # X and Y must be different if prolog.util.Token('NEQ', '\==') not in tokens and prolog.engine.ask_truth(engine_id, 'setof(X, (member(X, [william, alessandro, andrew]), brother(X, X)), L), length(L, 3)'): diff --git a/prolog/problems/family_relations/brother_2/sl.py b/prolog/problems/family_relations/brother_2/sl.py index 2d170aa..f8eba49 100644 --- a/prolog/problems/family_relations/brother_2/sl.py +++ b/prolog/problems/family_relations/brother_2/sl.py @@ -46,6 +46,11 @@ Na primer: <code>X \== Y</code></p> <p><code>Y</code> je pravzaprav lahko poljubnega spola.</p> ''', + 'nm_instead_of_neq': '''\ +<p>Uporabi raje operator \== namesto operatorja \=. Prvi preveri, da dva objekta nista enaka, +drugi pa ju poskusi unificirati (narediti enaka).</p> +''', + 'common_parent_needed': '''\ <p><img src="[%@resource Prolog_brother_05.svg%]" /></p> <p>Dobro bi bilo, da imata <code>X</code> in <code>Y</code> vsaj enega skupnega starša.</p> @@ -57,6 +62,7 @@ Na primer: <code>X \== Y</code></p> da spremenljivki, ki ju primerjaš, še nimata določene vrednosti in sta zato različni. Prolog ne preverja, če kasneje morda postaneta enaki, ampak samo kakšni sta v trenutku, ko naleti na primerjavo.</p> +<p>Morda pa preprosto preverjaš napačni spremenljivki?</p> ''', } |