diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-10 22:29:24 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-10 22:29:24 +0200 |
commit | 1b64321fda0bbf1f5a678671c1344eb2b87b5c74 (patch) | |
tree | 918743053a5b0b9a1ab45d6228c21e18af1132dc /prolog/problems/family_relations/sister_2 | |
parent | ee50df2225a974857e74d5ecb7c5f503e1c6b18a (diff) |
Use Hint classes for hints from the last commit
Also move the language-specific hint method for Prolog to prolog.common.
Diffstat (limited to 'prolog/problems/family_relations/sister_2')
-rw-r--r-- | prolog/problems/family_relations/sister_2/common.py | 24 | ||||
-rw-r--r-- | prolog/problems/family_relations/sister_2/sl.py | 12 |
2 files changed, 20 insertions, 16 deletions
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 = '''\ </pre>''' hint = { - 'general_hint_1': '''\ + 'general_hint': ['''\ <p><img src="Sister-1.png" /></p> -''', - - 'general_hint_2': '''\ +''', '''\ <p><img src="Sister-2.png" /></p> -''', - - 'general_hint_3': '''\ +''', '''\ <p><img src="Sister-2.png" /></p> <pre> parent(P, X) parent(P, Y) female(X) </pre> -''', +'''], 'x_y_must_be_different': '''\ <p>Si pomislil, da sta <code>X</code> in <code>Y</code> lahko ista oseba? Poskusi naslednjo poizvedbo:</p> |