From 1b64321fda0bbf1f5a678671c1344eb2b87b5c74 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 10 Sep 2015 22:29:24 +0200 Subject: Use Hint classes for hints from the last commit Also move the language-specific hint method for Prolog to prolog.common. --- .../problems/family_relations/sister_2/common.py | 24 ++++++++++++++-------- prolog/problems/family_relations/sister_2/sl.py | 12 ++++------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'prolog/problems/family_relations/sister_2') diff --git a/prolog/problems/family_relations/sister_2/common.py b/prolog/problems/family_relations/sister_2/common.py index e18a092..46d54f3 100644 --- a/prolog/problems/family_relations/sister_2/common.py +++ b/prolog/problems/family_relations/sister_2/common.py @@ -1,5 +1,11 @@ # coding=utf-8 +import socket +import prolog.engine +import prolog.util +from server.hints import Hint, HintSequence +import server.problems + id = 96 group = 'family_relations' number = 3 @@ -14,9 +20,13 @@ sister(X, Y) :- X \== Y. ''' -import prolog.engine -import prolog.util -import server.problems +hint_defs = { + 'general_hint': HintSequence('general_hint', 3), + 'x_must_be_female': Hint('x_must_be_female'), + 'common_parent_needed': Hint('common_parent_needed'), + 'Y_can_be_of_any_gender': Hint('Y_can_be_of_any_gender'), + 'x_y_must_be_different': Hint('x_y_must_be_different'), +} def test(session, program): # Test queries and expected answers (values of X). @@ -47,9 +57,6 @@ def test(session, program): return n_correct, len(queries) -def general_hint(): - pass - def hint(session, program): # how do I know which general hints were already shown? # how do I know enough time has elapsed for general hints to be shown? @@ -107,8 +114,9 @@ def hint(session, program): # this is the last code-specific hint (when everything else doesn't trigger anymore) ans = prolog.engine.ask_one(engine_id, 'setof(X, (member(X, [sally, nevia, vanessa]), sister(X, X)), L), length(L, N).') - if ans.get('N') == '3': - return [{'id': 'x_y_must_be_different'}] + # TODO this barfs if ans is 'false' + #if ans.get('N') == '3': + # return [{'id': 'x_y_must_be_different'}] # last hints are connected with programming style # here, this means detecting such code: diff --git a/prolog/problems/family_relations/sister_2/sl.py b/prolog/problems/family_relations/sister_2/sl.py index 5965bda..b2683c4 100644 --- a/prolog/problems/family_relations/sister_2/sl.py +++ b/prolog/problems/family_relations/sister_2/sl.py @@ -12,22 +12,18 @@ description = '''\ ''' hint = { - 'general_hint_1': '''\ + 'general_hint': ['''\

-''', - - 'general_hint_2': '''\ +''', '''\

-''', - - 'general_hint_3': '''\ +''', '''\

 parent(P, X)
 parent(P, Y)
 female(X)
 
-''', +'''], 'x_y_must_be_different': '''\

Si pomislil, da sta X in Y lahko ista oseba? Poskusi naslednjo poizvedbo:

-- cgit v1.2.1