diff options
Diffstat (limited to 'prolog/problems/lists/divide_3')
-rw-r--r-- | prolog/problems/lists/divide_3/common.py | 7 | ||||
-rw-r--r-- | prolog/problems/lists/divide_3/sl.py | 15 |
2 files changed, 17 insertions, 5 deletions
diff --git a/prolog/problems/lists/divide_3/common.py b/prolog/problems/lists/divide_3/common.py index 83a8a9e..1f14d2f 100644 --- a/prolog/problems/lists/divide_3/common.py +++ b/prolog/problems/lists/divide_3/common.py @@ -29,14 +29,11 @@ test_cases = [ [{'A': '[t, l, q, e, y, r]'}]), ] -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: diff --git a/prolog/problems/lists/divide_3/sl.py b/prolog/problems/lists/divide_3/sl.py new file mode 100644 index 0000000..ecf9a5a --- /dev/null +++ b/prolog/problems/lists/divide_3/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'divide/3' +slug = 'Razdeli dani seznam na dva podseznama (približno) enake velikosti' + +description = '''\ +<p><code>divide(L, L1, L2)</code>: seznam <code>L1</code> vsebuje elemente na lihih pozicijah v seznamu <code>L</code>, seznam <code>L2</code> pa elemente na sodih pozicijah v <code>L</code>.</p> +<pre> + ?- divide([a,b,c,d,e,f,g], X, Y). + X = [a,c,e,g], Y = [b,d,f]. + ?- divide([a,b,c,d,e,f], X, Y). + X = [a,c,e], Y = [b,d,f]. +</pre>''' + +hint = {} |