diff options
Diffstat (limited to 'prolog/problems/sets/union_3')
-rw-r--r-- | prolog/problems/sets/union_3/common.py | 11 | ||||
-rw-r--r-- | prolog/problems/sets/union_3/sl.py | 13 |
2 files changed, 16 insertions, 8 deletions
diff --git a/prolog/problems/sets/union_3/common.py b/prolog/problems/sets/union_3/common.py index 506913a..ae24943 100644 --- a/prolog/problems/sets/union_3/common.py +++ b/prolog/problems/sets/union_3/common.py @@ -34,20 +34,15 @@ test_cases = [ [{'X': '[0, 1, 2, 3, 5, 6, 9]'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems)) - +def test(code, aux_code): n_correct = 0 engine_id = None try: - engine_id, output = prolog.engine.create(code=code, timeout=1.0) + engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0) if engine_id is not None and 'error' not in map(itemgetter(0), output): # Engine successfully created, and no syntax error in program. for query, answers in test_cases: - # Limit inferences for each solution to curb unbounded recursion. - limited = 'call_with_inference_limit(({}), 100000, _)'.format(query) - if prolog.engine.check_answers(engine_id, query=limited, answers=answers, timeout=1.0): + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): n_correct += 1 finally: if engine_id: diff --git a/prolog/problems/sets/union_3/sl.py b/prolog/problems/sets/union_3/sl.py new file mode 100644 index 0000000..27d3088 --- /dev/null +++ b/prolog/problems/sets/union_3/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'union/3' +slug = 'Poišči unijo dveh množic' + +description = '''\ +<p><code>union(S1, S2, U)</code>: seznam <code>U</code> predstavlja unijo elementov v seznamih <code>S1</code> in <code>S2</code>, duplikatov (kot se za množice spodobi) ni.</p> +<pre> + ?- union([1,5,2,3], [3,4,8,2], U). + U = [1,5,3,4,8,2]. +</pre>''' + +hint = {} |