diff options
Diffstat (limited to 'prolog/problems/family_relations/sister_2')
-rw-r--r-- | prolog/problems/family_relations/sister_2/common.py | 9 | ||||
-rw-r--r-- | prolog/problems/family_relations/sister_2/sl.py | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/prolog/problems/family_relations/sister_2/common.py b/prolog/problems/family_relations/sister_2/common.py index 08f44b3..1bc9365 100644 --- a/prolog/problems/family_relations/sister_2/common.py +++ b/prolog/problems/family_relations/sister_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 = [ @@ -102,10 +103,14 @@ def hint(code, aux_code): # as this is after previous hints, by this stage the code probably # does return some sensible results already # this is an example of using the ordering of hints for easier trigger checks - if prolog.engine.ask_one(engine_id, - 'sister(_, Y), male(Y)') == 'false': + if prolog.engine.ask_truth(engine_id, 'sister(_, Y)') and \ + prolog.engine.ask_one(engine_id, 'sister(_, Y), male(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 # this is the last code-specific hint (when everything else doesn't trigger anymore) if prolog.util.Token('NEQ', '\==') not in tokens and prolog.engine.ask_truth(engine_id, diff --git a/prolog/problems/family_relations/sister_2/sl.py b/prolog/problems/family_relations/sister_2/sl.py index 6c36bce..5fa9d1c 100644 --- a/prolog/problems/family_relations/sister_2/sl.py +++ b/prolog/problems/family_relations/sister_2/sl.py @@ -4,7 +4,7 @@ name = 'sister/2' slug = 'X je sestra od Y' description = '''\ -<p><code>sister(?X, ?Y)</code>: <code>X</code> je sestra od <code>Y</code>. Primer:</p> +<p><code>sister(?X, ?Y)</code>: <code>X</code> je (pol)sestra od <code>Y</code>. Primer:</p> <pre> ?- sister(vanessa, Y). Y = patricia. @@ -45,6 +45,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_sister_05.svg%]" /></p> <p>Dobro bi bilo, da imata <code>X</code> in <code>Y</code> vsaj enega skupnega starša.</p> @@ -56,6 +61,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> ''', } |