From 49a2f24a813ca250d1c1f31f9799661ff70615ed Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 29 Feb 2016 00:11:26 +0100 Subject: Additional improvements to hints for mother, father, grandparent, sister, and brother problems. --- prolog/problems/family_relations/brother_2/common.py | 13 +++++++++---- prolog/problems/family_relations/brother_2/sl.py | 12 +++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'prolog/problems/family_relations/brother_2') diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py index 7f61744..0ad74c3 100644 --- a/prolog/problems/family_relations/brother_2/common.py +++ b/prolog/problems/family_relations/brother_2/common.py @@ -26,7 +26,8 @@ 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'), + 'neq+_instead_of_neq': Hint('neq+_instead_of_neq'), + 'predicate_always_false': Hint('predicate_always_false'), } test_cases = [ @@ -78,9 +79,13 @@ def hint(code, aux_code): 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'}] + # use of \= or =\= instead of \== + if prolog.util.Token('NEQU', '\=') in tokens or prolog.util.Token('NEQA', '=\=') in tokens: + return [{'id': 'neq+_instead_of_neq'}] + + # target predicate seems to always be false + if prolog.engine.ask_one(engine_id, 'brother(_, _)') == 'false': + return [{'id': 'predicate_always_false'}] # X and Y must be different if prolog.util.Token('NEQ', '\==') not in tokens and prolog.engine.ask_truth(engine_id, diff --git a/prolog/problems/family_relations/brother_2/sl.py b/prolog/problems/family_relations/brother_2/sl.py index f8eba49..ed2d015 100644 --- a/prolog/problems/family_relations/brother_2/sl.py +++ b/prolog/problems/family_relations/brother_2/sl.py @@ -46,9 +46,10 @@ Na primer: X \== Y

Y je pravzaprav lahko poljubnega spola.

''', - 'nm_instead_of_neq': '''\ -

Uporabi raje operator \== namesto operatorja \=. Prvi preveri, da dva objekta nista enaka, -drugi pa ju poskusi unificirati (narediti enaka).

+ 'neq+_instead_of_neq': '''\ +

Uporabi raje operator \== namesto operatorjev \= ali =\=. Prvi preveri, da oba operanda nista enaka, +drugi (\=) ju poskusi unificirati (narediti enaka), tretji (=\=) pa je samo za aritmetično primerjanje +in morata oba operanda biti takoj izračunljiva aritmetična izraza.

''', 'common_parent_needed': '''\ @@ -65,4 +66,9 @@ ko naleti na primerjavo.

Morda pa preprosto preverjaš napačni spremenljivki?

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

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?

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