diff options
Diffstat (limited to 'prolog/problems/family_relations')
-rw-r--r-- | prolog/problems/family_relations/brother_2/common.py | 25 | ||||
-rw-r--r-- | prolog/problems/family_relations/brother_2/sl.py | 12 | ||||
-rw-r--r-- | prolog/problems/family_relations/father_2/common.py | 21 | ||||
-rw-r--r-- | prolog/problems/family_relations/father_2/en.py | 2 | ||||
-rw-r--r-- | prolog/problems/family_relations/father_2/sl.py | 21 | ||||
-rw-r--r-- | prolog/problems/family_relations/mother_2/common.py | 20 | ||||
-rw-r--r-- | prolog/problems/family_relations/mother_2/sl.py | 12 | ||||
-rw-r--r-- | prolog/problems/family_relations/sister_2/common.py | 24 | ||||
-rw-r--r-- | prolog/problems/family_relations/sister_2/sl.py | 12 |
9 files changed, 84 insertions, 65 deletions
diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py index 41512e6..f2bfa15 100644 --- a/prolog/problems/family_relations/brother_2/common.py +++ b/prolog/problems/family_relations/brother_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 = 97 group = 'family_relations' number = 4 @@ -14,10 +20,13 @@ brother(X, Y) :- X \== Y. ''' -import prolog.engine -import prolog.util -import server.problems -import socket +hint_defs = { + 'general_hint': HintSequence('general_hint', 3), + 'x_must_be_male': Hint('x_must_be_male'), + '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): # TODO: change queries and answers (these are for sister/2) @@ -49,9 +58,6 @@ def test(session, program): return n_correct, len(queries) -def general_hint(): - pass - def hint(session, program): # tokens = prolog.util.tokenize(program) @@ -79,8 +85,9 @@ def hint(session, program): # X and Y must be different ans = prolog.engine.ask_one(engine_id, 'setof(X, (member(X, [william, alessandro, andrew]), brother(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'}] except socket.timeout as ex: pass diff --git a/prolog/problems/family_relations/brother_2/sl.py b/prolog/problems/family_relations/brother_2/sl.py index f9db389..ad1d6c2 100644 --- a/prolog/problems/family_relations/brother_2/sl.py +++ b/prolog/problems/family_relations/brother_2/sl.py @@ -13,22 +13,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) male(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> diff --git a/prolog/problems/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py index e1b46fd..81191d3 100644 --- a/prolog/problems/family_relations/father_2/common.py +++ b/prolog/problems/family_relations/father_2/common.py @@ -1,8 +1,14 @@ # coding=utf-8 -id = 999 # TODO: new id has to be defined for this problem +import socket +import prolog.engine +import prolog.util +from server.hints import Hint, HintSequence +import server.problems + +id = 181 group = 'family_relations' -number = 999 # TODO: this should be problem #2 +number = 2 visible = True facts = 'family_relations' @@ -12,9 +18,14 @@ father(X, Y) :- male(X). ''' -import prolog.engine -import prolog.util -import server.problems +hint_defs = { + 'general_hint': HintSequence('general_hint', 3), + 'or_instead_of_and': Hint('or_instead_of_and'), + 'x_must_be_male': Hint('x_must_be_male'), + 'x_must_be_parent': Hint('x_must_be_parent'), + 'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'), + 'y_need_not_be_parent': Hint('y_need_not_be_parent'), +} def test(session, program): # TODO: change queries and answers (these are for sister/2) diff --git a/prolog/problems/family_relations/father_2/en.py b/prolog/problems/family_relations/father_2/en.py index 108bb9b..59857a8 100644 --- a/prolog/problems/family_relations/father_2/en.py +++ b/prolog/problems/family_relations/father_2/en.py @@ -1,6 +1,6 @@ # coding=utf-8 -id = 94 +id = 181 name = 'mother/2' slug = 'the mother-child relation' diff --git a/prolog/problems/family_relations/father_2/sl.py b/prolog/problems/family_relations/father_2/sl.py index c9c38b7..8fb66c5 100644 --- a/prolog/problems/family_relations/father_2/sl.py +++ b/prolog/problems/family_relations/father_2/sl.py @@ -1,11 +1,12 @@ # coding=utf-8 -id = 94 -name = 'mother/2' -slug = 'X je mama od Y' +id = 181 +name = 'father/2' +slug = 'X je oče od Y' +# TODO fix example description = '''\ -<p><code>mother(X, Y)</code>: <code>X</code> je mama od <code>Y</code>.</p> +<p><code>father(X, Y)</code>: <code>X</code> je oče od <code>Y</code>.</p> <pre> ?- mother(tina, william). true. @@ -15,19 +16,15 @@ description = '''\ </pre>''' hint = { - 'general_hint_1': '''\ + 'general_hint': ['''\ <p><img src="Father-1.png" /></p> <p>Loni naj zbriše imena relacij (parent, mother) s te slike!</p> -''', - - 'general_hint_2': '''\ +''', '''\ <p><img src="Father-1.png" /></p> -''', - - 'general_hint_3': '''\ +''', '''\ <p>Če je <code>X</code> ženska in je hkrati <code>X</code> starš od <code>Y</code>, potem je <code>X</code> mama od <code>Y</code>.</p> -''', +'''], 'or_instead_of_and': '''\ <p>Si morda uporabil podpičje (ki pomeni ALI) namesto vejice (ki pomeni IN)?</p> diff --git a/prolog/problems/family_relations/mother_2/common.py b/prolog/problems/family_relations/mother_2/common.py index 613b721..09a641a 100644 --- a/prolog/problems/family_relations/mother_2/common.py +++ b/prolog/problems/family_relations/mother_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 = 94 group = 'family_relations' number = 1 @@ -12,9 +18,14 @@ mother(X, Y) :- female(X). ''' -import prolog.engine -import prolog.util -import server.problems +hint_defs = { + 'general_hint': HintSequence('general_hint', 3), + 'or_instead_of_and': Hint('or_instead_of_and'), + 'x_must_be_female': Hint('x_must_be_female'), + 'x_must_be_parent': Hint('x_must_be_parent'), + 'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'), + 'y_need_not_be_parent': Hint('y_need_not_be_parent'), +} def test(session, program): # TODO: change queries and answers (these are for sister/2) @@ -46,9 +57,6 @@ def test(session, program): return n_correct, len(queries) -def general_hint(): - pass - def hint(session, program): tokens = prolog.util.tokenize(program) diff --git a/prolog/problems/family_relations/mother_2/sl.py b/prolog/problems/family_relations/mother_2/sl.py index 8923eb5..5922d6c 100644 --- a/prolog/problems/family_relations/mother_2/sl.py +++ b/prolog/problems/family_relations/mother_2/sl.py @@ -15,19 +15,15 @@ description = '''\ </pre>''' hint = { - 'general_hint_1': '''\ + 'general_hint': ['''\ <p><img src="Mother-1.png" /></p> <p>Loni naj zbriše imena relacij (parent, mother) s te slike!</p> -''', - - 'general_hint_2': '''\ +''', '''\ <p><img src="Mother-1.png" /></p> -''', - - 'general_hint_3': '''\ +''', '''\ <p>Če je <code>X</code> ženska in je hkrati <code>X</code> starš od <code>Y</code>, potem je <code>X</code> mama od <code>Y</code>.</p> -''', +'''], 'or_instead_of_and': '''\ <p>Si morda uporabil podpičje (ki pomeni ALI) namesto vejice (ki pomeni IN)?</p> 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> |