summaryrefslogtreecommitdiff
path: root/prolog/problems/family_relations/brother_2
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-11 12:02:16 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-11 12:02:16 +0200
commit64873173e6bb758cd22b60df55cf4415b8651359 (patch)
tree6d579346a64cdd45bd0a87a00967c6a0b545928c /prolog/problems/family_relations/brother_2
parentf42daa8b31b5772f60d8d8656ad2a5d5d6fd6f67 (diff)
Accept a list of solved problems for hint/test
Some Prolog problems may be solved using previous solutions. This allows us to test such programs, and still analyze the submission separately.
Diffstat (limited to 'prolog/problems/family_relations/brother_2')
-rw-r--r--prolog/problems/family_relations/brother_2/common.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py
index 4c8a4f3..48bc519 100644
--- a/prolog/problems/family_relations/brother_2/common.py
+++ b/prolog/problems/family_relations/brother_2/common.py
@@ -28,7 +28,7 @@ hint_typs = {
'x_y_must_be_different': Hint('x_y_must_be_different'),
}
-def test(session, program):
+def test(program, solved_problems):
# TODO: change queries and answers (these are for sister/2)
# Test queries and expected answers (values of X).
queries = [
@@ -37,7 +37,9 @@ def test(session, program):
('sister(X, _)', set(['michelle', 'daniela', 'patricia', 'luana', 'sally', 'melanie', 'nevia', 'vanessa', 'anna'])),
]
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
engine_id = None
try:
@@ -58,10 +60,13 @@ def test(session, program):
return n_correct, len(queries)
-def hint(session, program):
+def hint(program, solved_problems):
# tokens = prolog.util.tokenize(program)
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
+
engine_id = None
try:
engine_id, output = prolog.engine.create(code=code, timeout=1.0)