From 384d3c501a38b489312496b0bf9522bdf29053d8 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 14 Dec 2015 13:57:29 +0100 Subject: Add Slovenian translations for Prolog exercises --- prolog/problems/lists/conc_3/sl.py | 15 +++++++++++++++ prolog/problems/lists/count_3/sl.py | 13 +++++++++++++ prolog/problems/lists/del_3/sl.py | 20 ++++++++++++++++++++ prolog/problems/lists/divide_3/sl.py | 15 +++++++++++++++ prolog/problems/lists/dup_2/sl.py | 15 +++++++++++++++ prolog/problems/lists/evenlen_1_+_oddlen_1/sl.py | 18 ++++++++++++++++++ prolog/problems/lists/insert_3/sl.py | 15 +++++++++++++++ prolog/problems/lists/len_2/sl.py | 13 +++++++++++++ prolog/problems/lists/max_2/sl.py | 15 +++++++++++++++ prolog/problems/lists/memb_2/sl.py | 17 +++++++++++++++++ prolog/problems/lists/min_2/sl.py | 15 +++++++++++++++ prolog/problems/lists/palindrome_1/sl.py | 15 +++++++++++++++ prolog/problems/lists/permute_2/sl.py | 18 ++++++++++++++++++ prolog/problems/lists/rev_2/en.py | 4 ++-- prolog/problems/lists/rev_2/sl.py | 15 +++++++++++++++ prolog/problems/lists/shiftleft_2/sl.py | 13 +++++++++++++ prolog/problems/lists/shiftright_2/sl.py | 13 +++++++++++++ prolog/problems/lists/sublist_2/sl.py | 19 +++++++++++++++++++ prolog/problems/lists/sum_2/sl.py | 13 +++++++++++++ 19 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 prolog/problems/lists/conc_3/sl.py create mode 100644 prolog/problems/lists/count_3/sl.py create mode 100644 prolog/problems/lists/del_3/sl.py create mode 100644 prolog/problems/lists/divide_3/sl.py create mode 100644 prolog/problems/lists/dup_2/sl.py create mode 100644 prolog/problems/lists/evenlen_1_+_oddlen_1/sl.py create mode 100644 prolog/problems/lists/insert_3/sl.py create mode 100644 prolog/problems/lists/len_2/sl.py create mode 100644 prolog/problems/lists/max_2/sl.py create mode 100644 prolog/problems/lists/memb_2/sl.py create mode 100644 prolog/problems/lists/min_2/sl.py create mode 100644 prolog/problems/lists/palindrome_1/sl.py create mode 100644 prolog/problems/lists/permute_2/sl.py create mode 100644 prolog/problems/lists/rev_2/sl.py create mode 100644 prolog/problems/lists/shiftleft_2/sl.py create mode 100644 prolog/problems/lists/shiftright_2/sl.py create mode 100644 prolog/problems/lists/sublist_2/sl.py create mode 100644 prolog/problems/lists/sum_2/sl.py (limited to 'prolog/problems/lists') diff --git a/prolog/problems/lists/conc_3/sl.py b/prolog/problems/lists/conc_3/sl.py new file mode 100644 index 0000000..15e3163 --- /dev/null +++ b/prolog/problems/lists/conc_3/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'conc/3' +slug = 'Združi dva seznama (konkatenacija)' + +description = '''\ +

conc(L1, L2, L): seznam L dobiš tako, da seznamu L1 na konec dodaš elemente seznama L2.

+
+  ?- conc([1,2], [3,4], X).
+    X = [1,2,3,4].
+  ?- conc(X, [], [1,2,3]).
+    X = [1,2,3].
+
''' + +hint = {} diff --git a/prolog/problems/lists/count_3/sl.py b/prolog/problems/lists/count_3/sl.py new file mode 100644 index 0000000..15a4650 --- /dev/null +++ b/prolog/problems/lists/count_3/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'count/3' +slug = 'Preštej kolikokrat se element pojavi v seznamu' + +description = '''\ +

count(X, L, N): N je število kolikokrat se element X pojavi v seznamu L.

+
+  ?- count(1, [1,2,1,3,1], N).
+    N = 3.
+
''' + +hint = {} diff --git a/prolog/problems/lists/del_3/sl.py b/prolog/problems/lists/del_3/sl.py new file mode 100644 index 0000000..49ab16f --- /dev/null +++ b/prolog/problems/lists/del_3/sl.py @@ -0,0 +1,20 @@ +# coding=utf-8 + +name = 'del/3' +slug = 'Zbriši element iz seznama' + +description = '''\ +

del(X, L1, L2): seznam L2 dobimo iz seznama L1 tako da zbrišemo element X.

+
+  ?- del(1, [1,2,3], L).
+    L = [2,3].
+  ?- del(2, [1,2,3,2,5], L).
+    L = [1,3,2,5] ;
+    L = [1,2,3,5].
+  ?- del(X, [1,2,3], L).
+    X = 1, L = [2,3] ;
+    X = 2, L = [1,3] ;
+    X = 3, L = [1,2].
+
''' + +hint = {} 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 = '''\ +

divide(L, L1, L2): seznam L1 vsebuje elemente na lihih pozicijah v seznamu L, seznam L2 pa elemente na sodih pozicijah v L.

+
+  ?- 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].
+
''' + +hint = {} diff --git a/prolog/problems/lists/dup_2/sl.py b/prolog/problems/lists/dup_2/sl.py new file mode 100644 index 0000000..fc974d8 --- /dev/null +++ b/prolog/problems/lists/dup_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'dup/2' +slug = 'Podvoji vse elemente v seznamu' + +description = '''\ +

dup(L1, L2): seznam L2 dobimo iz L1 tako, da podvojimo vsak element.

+
+  ?- dup([1,2], X).
+    X = [1,1,2,2].
+  ?- dup([1,2,3], X).
+    X = [1,1,2,2,3,3].
+
''' + +hint = {} diff --git a/prolog/problems/lists/evenlen_1_+_oddlen_1/sl.py b/prolog/problems/lists/evenlen_1_+_oddlen_1/sl.py new file mode 100644 index 0000000..1959877 --- /dev/null +++ b/prolog/problems/lists/evenlen_1_+_oddlen_1/sl.py @@ -0,0 +1,18 @@ +# coding=utf-8 + +name = 'evenlen/1 + oddlen/1' +slug = 'Brez aritmetike preveri, če je seznam sode ali lihe dolžine' + +description = '''\ +

evenlen(L): seznam L ima sodo število elementov.
+oddlen(L): seznam L ima liho število elementov.

+
+  ?- oddlen([1,2,3,4,5]).
+    true.
+  ?- oddlen([1,2,3,4]).
+    false.
+  ?- evenlen([1,2,3,4]).
+    true.
+
''' + +hint = {} diff --git a/prolog/problems/lists/insert_3/sl.py b/prolog/problems/lists/insert_3/sl.py new file mode 100644 index 0000000..08ffced --- /dev/null +++ b/prolog/problems/lists/insert_3/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'insert/3' +slug = 'Vstavi element na poljubno mesto v seznamu' + +description = '''\ +

insert(X, L1, L2): seznam L2 dobimo iz L1 tako, da vstavimo element X na poljubno mesto. Predikat naj vrne vse možne rešitve, eno za drugo.

+
+  ?- insert(1, [2,3], L).
+    L = [1,2,3] ;
+    L = [2,1,3] ;
+    L = [2,3,1].
+
''' + +hint = {} diff --git a/prolog/problems/lists/len_2/sl.py b/prolog/problems/lists/len_2/sl.py new file mode 100644 index 0000000..5b9f05a --- /dev/null +++ b/prolog/problems/lists/len_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'len/2' +slug = 'Izračunaj dolžino danega seznama' + +description = '''\ +

len(L, Len): Len je dolžina seznama L.

+
+  ?- len([1,2,3], Len).
+    Len = 3.
+
''' + +hint = {} diff --git a/prolog/problems/lists/max_2/sl.py b/prolog/problems/lists/max_2/sl.py new file mode 100644 index 0000000..81c354b --- /dev/null +++ b/prolog/problems/lists/max_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'max/2' +slug = 'Poišči največji element v danem seznamu' + +description = '''\ +

max(L, Max): Max je največji element v seznamu L.

+
+  ?- max([5,4,1,6], M).
+    M = 6.
+  ?- max([3,2,2], M).
+    M = 3.
+
''' + +hint = {} diff --git a/prolog/problems/lists/memb_2/sl.py b/prolog/problems/lists/memb_2/sl.py new file mode 100644 index 0000000..540394b --- /dev/null +++ b/prolog/problems/lists/memb_2/sl.py @@ -0,0 +1,17 @@ +# coding=utf-8 + +name = 'memb/2' +slug = 'Preveri (poišči), če je dani element v seznamu' + +description = '''\ +

memb(E, L): E je element seznama L.

+
+  ?- memb(X, [1,2,3]).
+    X = 1 ;
+    X = 2 ;
+    X = 3.
+  ?- memb(1, [3,2,X]).
+    X = 1.
+
''' + +hint = {} diff --git a/prolog/problems/lists/min_2/sl.py b/prolog/problems/lists/min_2/sl.py new file mode 100644 index 0000000..6a5964b --- /dev/null +++ b/prolog/problems/lists/min_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'min/2' +slug = 'Poišči najmanjši element v danem seznamu' + +description = '''\ +

min(L, Min): Min je najmanjši element v seznamu L.

+
+  ?- min([5,4,1,6], M).
+    M = 1.
+  ?- min([3,2,2], M).
+    M = 2.
+
''' + +hint = {} diff --git a/prolog/problems/lists/palindrome_1/sl.py b/prolog/problems/lists/palindrome_1/sl.py new file mode 100644 index 0000000..04f1f59 --- /dev/null +++ b/prolog/problems/lists/palindrome_1/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'palindrome/1' +slug = 'Preveri, če elementi seznama tvorijo palindrom' + +description = '''\ +

palindrome(L): Elementi seznama L se preberejo v istem vrstnem redu z začetka in s konca seznama.

+
+  ?- palindrome([1,2,3,2,1]).
+    true.
+  ?- palindrome([1,2,3]).
+    false.
+
''' + +hint = {} diff --git a/prolog/problems/lists/permute_2/sl.py b/prolog/problems/lists/permute_2/sl.py new file mode 100644 index 0000000..2c98340 --- /dev/null +++ b/prolog/problems/lists/permute_2/sl.py @@ -0,0 +1,18 @@ +# coding=utf-8 + +name = 'permute/2' +slug = 'Generiraj permutacije elementov v seznamu' + +description = '''\ +

permute(L1, L2): seznam L2 je permutacija vrstnega reda elementov v seznamu L1.

+
+  ?- permute([1,2,3], L).
+    L = [1,2,3] ;
+    L = [1,3,2] ;
+    L = [2,1,3] ;
+    L = [2,3,1] ;
+    L = [3,1,2] ;
+    L = [3,2,1].
+
''' + +hint = {} diff --git a/prolog/problems/lists/rev_2/en.py b/prolog/problems/lists/rev_2/en.py index fe36ec5..7941f9e 100644 --- a/prolog/problems/lists/rev_2/en.py +++ b/prolog/problems/lists/rev_2/en.py @@ -6,10 +6,10 @@ slug = 'reverse a list' description = '''\

rev(L1, L2): the list L2 is obtained from L1 by reversing the order of the elements.

-  ?- rev([], X).
-    X = [].
   ?- rev([1,2,3], X).
     X = [3,2,1].
+  ?- rev([], X).
+    X = [].
 
''' hint = {} diff --git a/prolog/problems/lists/rev_2/sl.py b/prolog/problems/lists/rev_2/sl.py new file mode 100644 index 0000000..95ba8b7 --- /dev/null +++ b/prolog/problems/lists/rev_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'rev/2' +slug = 'Obrni seznam' + +description = '''\ +

rev(L1, L2): seznam L2 ima elemente v obratnem vrstnem redu kot seznam L1.

+
+  ?- rev([1,2,3], X).
+    X = [3,2,1].
+  ?- rev([], X).
+    X = [].
+
''' + +hint = {} diff --git a/prolog/problems/lists/shiftleft_2/sl.py b/prolog/problems/lists/shiftleft_2/sl.py new file mode 100644 index 0000000..44e726f --- /dev/null +++ b/prolog/problems/lists/shiftleft_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'shiftleft/2' +slug = 'Premakni elemente seznama za eno mesto v levo' + +description = '''\ +

shiftleft(L1, L2): elemente v seznamu L1 za eno mesto premaknemo v levo ("circular shift").

+
+  ?- shiftleft([1,2,3,4,5], X).
+    X = [2,3,4,5,1].
+
''' + +hint = {} diff --git a/prolog/problems/lists/shiftright_2/sl.py b/prolog/problems/lists/shiftright_2/sl.py new file mode 100644 index 0000000..9d84510 --- /dev/null +++ b/prolog/problems/lists/shiftright_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'shiftright/2' +slug = 'Premakni elemente seznama za eno mesto v desno' + +description = '''\ +

shiftright(L1, L2): elemente v seznamu L1 za eno mesto premaknemo v desno ("circular shift").

+
+  ?- shiftright([1,2,3,4,5], X).
+    X = [5,1,2,3,4].
+
''' + +hint = {} diff --git a/prolog/problems/lists/sublist_2/sl.py b/prolog/problems/lists/sublist_2/sl.py new file mode 100644 index 0000000..27d9b54 --- /dev/null +++ b/prolog/problems/lists/sublist_2/sl.py @@ -0,0 +1,19 @@ +# coding=utf-8 + +name = 'sublist/2' +slug = 'Generiraj vse podsezname danega seznama' + +description = '''\ +

sublist(L, SL): SL je podseznam seznama L. Predikat naj vrne vse možne podsezname, enega po enega.

+
+  ?- sublist([1,2,3], X).
+    X = [] ;
+    X = [1] ;
+    X = [1,2] ;
+    X = [1,2,3] ;
+    X = [2] ;
+    X = [2,3] ;
+    X = [3].
+
''' + +hint = {} diff --git a/prolog/problems/lists/sum_2/sl.py b/prolog/problems/lists/sum_2/sl.py new file mode 100644 index 0000000..0e1e6d6 --- /dev/null +++ b/prolog/problems/lists/sum_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'sum/2' +slug = 'Izračunaj vsoto elementov v seznamu' + +description = '''\ +

sum(L, Sum): Sum je vsota vseh elementov v seznamu L.

+
+  ?- sum([1,2,3], Sum).
+    Sum = 6.
+
''' + +hint = {} -- cgit v1.2.1 From 766e2ba30413850ab43842de0aa3e9a80c5e7236 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 23 Dec 2015 16:19:06 +0100 Subject: Add info about reusable solutions to Prolog groups --- prolog/problems/lists/common.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'prolog/problems/lists') diff --git a/prolog/problems/lists/common.py b/prolog/problems/lists/common.py index 4788fc4..e7dd0d7 100644 --- a/prolog/problems/lists/common.py +++ b/prolog/problems/lists/common.py @@ -1,2 +1,4 @@ id = 2 number = 2 + +allowed_groups = ['lists'] -- cgit v1.2.1 From c1bb0d56b2c0482c766d094c65fdf0fd9d1aa0ba Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 23 Dec 2015 16:23:43 +0100 Subject: Simplify Prolog test function --- prolog/problems/lists/conc_3/common.py | 7 ++----- prolog/problems/lists/count_3/common.py | 7 ++----- prolog/problems/lists/del_3/common.py | 7 ++----- prolog/problems/lists/divide_3/common.py | 7 ++----- prolog/problems/lists/dup_2/common.py | 7 ++----- prolog/problems/lists/evenlen_1_+_oddlen_1/common.py | 7 ++----- prolog/problems/lists/insert_3/common.py | 7 ++----- prolog/problems/lists/len_2/common.py | 7 ++----- prolog/problems/lists/max_2/common.py | 7 ++----- prolog/problems/lists/memb_2/common.py | 7 ++----- prolog/problems/lists/min_2/common.py | 7 ++----- prolog/problems/lists/palindrome_1/common.py | 7 ++----- prolog/problems/lists/permute_2/common.py | 7 ++----- prolog/problems/lists/rev_2/common.py | 7 ++----- prolog/problems/lists/shiftleft_2/common.py | 7 ++----- prolog/problems/lists/shiftright_2/common.py | 7 ++----- prolog/problems/lists/sublist_2/common.py | 7 ++----- prolog/problems/lists/sum_2/common.py | 7 ++----- 18 files changed, 36 insertions(+), 90 deletions(-) (limited to 'prolog/problems/lists') diff --git a/prolog/problems/lists/conc_3/common.py b/prolog/problems/lists/conc_3/common.py index 6efac47..ffd8f0f 100644 --- a/prolog/problems/lists/conc_3/common.py +++ b/prolog/problems/lists/conc_3/common.py @@ -26,14 +26,11 @@ test_cases = [ [{}]), ] -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/count_3/common.py b/prolog/problems/lists/count_3/common.py index c257d66..7970240 100644 --- a/prolog/problems/lists/count_3/common.py +++ b/prolog/problems/lists/count_3/common.py @@ -30,14 +30,11 @@ test_cases = [ [{'X': '2'}]), ] -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/del_3/common.py b/prolog/problems/lists/del_3/common.py index 5e00f4d..d0e4a29 100644 --- a/prolog/problems/lists/del_3/common.py +++ b/prolog/problems/lists/del_3/common.py @@ -24,14 +24,11 @@ test_cases = [ [{'X': 'g', 'Y': 'u', 'Z': 'f'}]), ] -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/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/dup_2/common.py b/prolog/problems/lists/dup_2/common.py index cce5aef..66b9c64 100644 --- a/prolog/problems/lists/dup_2/common.py +++ b/prolog/problems/lists/dup_2/common.py @@ -26,14 +26,11 @@ test_cases = [ [{'X': '[k, f, f, g, a]'}]), ] -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/evenlen_1_+_oddlen_1/common.py b/prolog/problems/lists/evenlen_1_+_oddlen_1/common.py index 13d9bca..b683cf7 100644 --- a/prolog/problems/lists/evenlen_1_+_oddlen_1/common.py +++ b/prolog/problems/lists/evenlen_1_+_oddlen_1/common.py @@ -32,14 +32,11 @@ test_cases = [ [{}]), ] -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/insert_3/common.py b/prolog/problems/lists/insert_3/common.py index fe1fbb6..7d92726 100644 --- a/prolog/problems/lists/insert_3/common.py +++ b/prolog/problems/lists/insert_3/common.py @@ -26,14 +26,11 @@ test_cases = [ [{'A': 'c', 'X': 'i'}]), ] -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/len_2/common.py b/prolog/problems/lists/len_2/common.py index 94a05c5..538db56 100644 --- a/prolog/problems/lists/len_2/common.py +++ b/prolog/problems/lists/len_2/common.py @@ -25,14 +25,11 @@ test_cases = [ [{'X': '0'}]), ] -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/max_2/common.py b/prolog/problems/lists/max_2/common.py index 1f8769a..6fd9a4d 100644 --- a/prolog/problems/lists/max_2/common.py +++ b/prolog/problems/lists/max_2/common.py @@ -29,14 +29,11 @@ test_cases = [ [{'X': '-22'}]), ] -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/memb_2/common.py b/prolog/problems/lists/memb_2/common.py index 30a6dfd..691471f 100644 --- a/prolog/problems/lists/memb_2/common.py +++ b/prolog/problems/lists/memb_2/common.py @@ -22,14 +22,11 @@ test_cases = [ [{'X': 'y'}, {'X': 'l'}, {'X': 'r'}, {'X': 'g'}, {'X': 'a'}]), ] -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/min_2/common.py b/prolog/problems/lists/min_2/common.py index fc505b7..65ce979 100644 --- a/prolog/problems/lists/min_2/common.py +++ b/prolog/problems/lists/min_2/common.py @@ -29,14 +29,11 @@ test_cases = [ [{'X': '-22'}]), ] -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/palindrome_1/common.py b/prolog/problems/lists/palindrome_1/common.py index 044f7be..7050c8c 100644 --- a/prolog/problems/lists/palindrome_1/common.py +++ b/prolog/problems/lists/palindrome_1/common.py @@ -30,14 +30,11 @@ test_cases = [ [{'X': 'b'}]), ] -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/permute_2/common.py b/prolog/problems/lists/permute_2/common.py index 5ade0b5..162b018 100644 --- a/prolog/problems/lists/permute_2/common.py +++ b/prolog/problems/lists/permute_2/common.py @@ -28,14 +28,11 @@ test_cases = [ [{'X': '[[b, e, l], [b, l, e], [e, b, l], [e, l, b], [l, b, e], [l, e, b]]'}]), ] -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/rev_2/common.py b/prolog/problems/lists/rev_2/common.py index 2a16e27..f5e4d9c 100644 --- a/prolog/problems/lists/rev_2/common.py +++ b/prolog/problems/lists/rev_2/common.py @@ -28,14 +28,11 @@ test_cases = [ [{'X': '[d, d, c, k, s]'}]), ] -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/shiftleft_2/common.py b/prolog/problems/lists/shiftleft_2/common.py index 8de545b..6f3576b 100644 --- a/prolog/problems/lists/shiftleft_2/common.py +++ b/prolog/problems/lists/shiftleft_2/common.py @@ -26,14 +26,11 @@ test_cases = [ [{'A': 'x', 'B': 'y', 'C': 'l', 'D': 'c', 'E': 'h'}]), ] -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/shiftright_2/common.py b/prolog/problems/lists/shiftright_2/common.py index 205daa9..3084f9f 100644 --- a/prolog/problems/lists/shiftright_2/common.py +++ b/prolog/problems/lists/shiftright_2/common.py @@ -26,14 +26,11 @@ test_cases = [ [{'A': 'x', 'B': 'y', 'C': 'c', 'D': 'h', 'E': 'l'}]), ] -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/sublist_2/common.py b/prolog/problems/lists/sublist_2/common.py index bcf3315..e2d8964 100644 --- a/prolog/problems/lists/sublist_2/common.py +++ b/prolog/problems/lists/sublist_2/common.py @@ -29,14 +29,11 @@ test_cases = [ [{'X': '[[], [a], [a, b], [a, b, c], [b], [b, c], [c]]'}]), ] -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/sum_2/common.py b/prolog/problems/lists/sum_2/common.py index a849601..568cfca 100644 --- a/prolog/problems/lists/sum_2/common.py +++ b/prolog/problems/lists/sum_2/common.py @@ -25,14 +25,11 @@ test_cases = [ [{'X': '4'}]), ] -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: -- cgit v1.2.1