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 --- .../license_plates/checklicenseplate_3/sl.py | 18 ++++++++++++++++++ prolog/problems/license_plates/firstminus_2/sl.py | 14 ++++++++++++++ prolog/problems/license_plates/genexp_2/sl.py | 19 +++++++++++++++++++ prolog/problems/license_plates/getdigits_2/sl.py | 13 +++++++++++++ prolog/problems/license_plates/joindigits_2/sl.py | 16 ++++++++++++++++ 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 +++++++++++++ prolog/problems/sets/diff_3/sl.py | 13 +++++++++++++ prolog/problems/sets/intersect_3/sl.py | 13 +++++++++++++ prolog/problems/sets/is_subset_2/sl.py | 15 +++++++++++++++ prolog/problems/sets/is_superset_2/sl.py | 15 +++++++++++++++ prolog/problems/sets/powerset_2/sl.py | 13 +++++++++++++ prolog/problems/sets/subset_2/sl.py | 20 ++++++++++++++++++++ prolog/problems/sets/union_3/sl.py | 13 +++++++++++++ prolog/problems/sorting/is_sorted_1/sl.py | 15 +++++++++++++++ prolog/problems/sorting/isort_2/sl.py | 13 +++++++++++++ prolog/problems/sorting/pivoting_4/sl.py | 13 +++++++++++++ prolog/problems/sorting/quick_sort_2/sl.py | 13 +++++++++++++ prolog/problems/sorting/sins_3/sl.py | 15 +++++++++++++++ prolog/problems/sorting/slowest_sort_ever_2/sl.py | 13 +++++++++++++ 37 files changed, 543 insertions(+), 2 deletions(-) create mode 100644 prolog/problems/license_plates/checklicenseplate_3/sl.py create mode 100644 prolog/problems/license_plates/firstminus_2/sl.py create mode 100644 prolog/problems/license_plates/genexp_2/sl.py create mode 100644 prolog/problems/license_plates/getdigits_2/sl.py create mode 100644 prolog/problems/license_plates/joindigits_2/sl.py 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 create mode 100644 prolog/problems/sets/diff_3/sl.py create mode 100644 prolog/problems/sets/intersect_3/sl.py create mode 100644 prolog/problems/sets/is_subset_2/sl.py create mode 100644 prolog/problems/sets/is_superset_2/sl.py create mode 100644 prolog/problems/sets/powerset_2/sl.py create mode 100644 prolog/problems/sets/subset_2/sl.py create mode 100644 prolog/problems/sets/union_3/sl.py create mode 100644 prolog/problems/sorting/is_sorted_1/sl.py create mode 100644 prolog/problems/sorting/isort_2/sl.py create mode 100644 prolog/problems/sorting/pivoting_4/sl.py create mode 100644 prolog/problems/sorting/quick_sort_2/sl.py create mode 100644 prolog/problems/sorting/sins_3/sl.py create mode 100644 prolog/problems/sorting/slowest_sort_ever_2/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/license_plates/checklicenseplate_3/sl.py b/prolog/problems/license_plates/checklicenseplate_3/sl.py new file mode 100644 index 0000000..2e3ec65 --- /dev/null +++ b/prolog/problems/license_plates/checklicenseplate_3/sl.py @@ -0,0 +1,18 @@ +# coding=utf-8 + +name = 'checkLicensePlate/3' +slug = 'Preveri, če lahko iz številk v registrski tablici sestaviš veljavno enačbo' + +description = '''\ +

checkLicensePlate(LP, E1, E2): iz cifer v seznamu LP se da sestaviti veljavno enačbo E1 = E2. E1 in E2 sta aritmetična izraza, sestavljena iz podseznamov Plate z uporabo aritmetičnih operatorjev (+, -, * and /). Dodaten unarni minus se lahko vstavi na začetek izrazov E1 in E2.

+
+  ?- checkLicensePlate([l,j,l,3,-,2,1,7], E1, E2).
+    E1 = 3,       E2 = 21/7 ;
+    E1 = -3,      E2 = -21/7 ;
+    E1 = 3*2,     E2 = -1+7 ;
+    E1 = -3*2,    E2 = 1-7 ;
+    E1 = 3*2+1,   E2 = 7 ;
+    E1 = -3*2-1,  E2 = -7.
+
''' + +hint = {} diff --git a/prolog/problems/license_plates/firstminus_2/sl.py b/prolog/problems/license_plates/firstminus_2/sl.py new file mode 100644 index 0000000..d480994 --- /dev/null +++ b/prolog/problems/license_plates/firstminus_2/sl.py @@ -0,0 +1,14 @@ +# coding=utf-8 + +name = 'firstMinus/2' +slug = 'Negiraj prvi element v danem seznamu števil' + +description = '''\ +

firstMinus(L1, L2): seznam L2 je enak kot L1, razen prvega elementa, ki je lahko negiran ali pa ne. Predikat naj vrne obe rešitvi, eno za drugo.

+
+  ?- firstMinus([1,2,3], L).
+    L = [1,2,3] ;
+    L = [-1,2,3].
+
''' + +hint = {} diff --git a/prolog/problems/license_plates/genexp_2/sl.py b/prolog/problems/license_plates/genexp_2/sl.py new file mode 100644 index 0000000..9160f27 --- /dev/null +++ b/prolog/problems/license_plates/genexp_2/sl.py @@ -0,0 +1,19 @@ +# coding=utf-8 + +name = 'genexp/2' +slug = 'Sestavi aritmetični izraz iz številk v podanem seznamu' + +description = '''\ +

genexp(L, E): Izraz E je zgrajen iz številk v seznamu L z dodajanjem aritmetičnih operatorjev. Predikat naj vrača vse možne izraze, enega po enega.

+
+  ?- genexp([1,2,3], L).
+    L = 1+2+3 ;
+    L = 1+2-3 ;
+    L = (1+2)*3 ;
+    L = (1+2)/3 ;
+    L = 1-2+3 ;
+    L = 1-2-3 ;
+    ...
+
''' + +hint = {} diff --git a/prolog/problems/license_plates/getdigits_2/sl.py b/prolog/problems/license_plates/getdigits_2/sl.py new file mode 100644 index 0000000..3f59e90 --- /dev/null +++ b/prolog/problems/license_plates/getdigits_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'getdigits/2' +slug = 'Vrni vse številke iz podanega seznama' + +description = '''\ +

getdigits(L, DL): seznam DL vsebuje vse številke iz seznama L, vrstni red elementov se ohrani.

+
+  ?- getdigits([2,3,e,-,4,b], DL).
+    DL = [2,3,4].
+
''' + +hint = {} diff --git a/prolog/problems/license_plates/joindigits_2/sl.py b/prolog/problems/license_plates/joindigits_2/sl.py new file mode 100644 index 0000000..344d849 --- /dev/null +++ b/prolog/problems/license_plates/joindigits_2/sl.py @@ -0,0 +1,16 @@ +# coding=utf-8 + +name = 'joindigits/2' +slug = 'Združi sosednja števila v seznamu na vse možne načine' + +description = '''\ +

joindigits(L, NL): seznam NL dobimo iz seznama L tako, da poljubno združujemo sosednja števila. Predikat naj vrača vse možnosti, eno po eno.

+
+  ?- joindigits([3,2,4], NL).
+    NL = [324] ;
+    NL = [32,4] ;
+    NL = [3,24] ;
+    NL = [3,2,4].
+
''' + +hint = {} 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 = {} diff --git a/prolog/problems/sets/diff_3/sl.py b/prolog/problems/sets/diff_3/sl.py new file mode 100644 index 0000000..d9b89e7 --- /dev/null +++ b/prolog/problems/sets/diff_3/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'diff/3' +slug = 'Poišči razliko dveh množic' + +description = '''\ +

diff(S1, S2, D): seznam D vsebuje elemente iz S1, ki niso v S2.

+
+  ?- diff([2,3,5,1,7,9], [3,7,4,5,6], D).
+    D = [2,1,9].
+
''' + +hint = {} diff --git a/prolog/problems/sets/intersect_3/sl.py b/prolog/problems/sets/intersect_3/sl.py new file mode 100644 index 0000000..a6af2d5 --- /dev/null +++ b/prolog/problems/sets/intersect_3/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'intersect/3' +slug = 'Poišči presek dveh množic' + +description = '''\ +

intersect(S1, S2, I): seznam I vsebuje presek elementov v S1 in S2.

+
+  ?- intersect([1,5,6,3,4,2], [8,1,5,9,4,3], I).
+    I = [1,5,3,4].
+
''' + +hint = {} diff --git a/prolog/problems/sets/is_subset_2/sl.py b/prolog/problems/sets/is_subset_2/sl.py new file mode 100644 index 0000000..ccec5b0 --- /dev/null +++ b/prolog/problems/sets/is_subset_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'is_subset/2' +slug = 'Preveri, če je prva množica podmnožica od druge' + +description = '''\ +

is_subset(S1, S2): množica S1 je podmnožica od S2.

+
+  ?- is_subset([2,1,3,5,0], [3,2,1,4,5,9]).
+    false.
+  ?- is_subset([2,1,3,5], [3,2,1,4,5,9]).
+    true.
+
''' + +hint = {} diff --git a/prolog/problems/sets/is_superset_2/sl.py b/prolog/problems/sets/is_superset_2/sl.py new file mode 100644 index 0000000..77d0d9d --- /dev/null +++ b/prolog/problems/sets/is_superset_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'is_superset/2' +slug = 'Preveri, če je prva množica nadmnožica od druge' + +description = '''\ +

is_superset(S1, S2): množica S1 je nadmnožica (vsebuje vse elemente) od S2.

+
+  ?- is_superset([3,2,1,4,5,9], [2,1,3,5]).
+    true.
+  ?- is_superset([3,2,1,4,5,9], [2,1,3,5,0]).
+    false.
+
''' + +hint = {} diff --git a/prolog/problems/sets/powerset_2/sl.py b/prolog/problems/sets/powerset_2/sl.py new file mode 100644 index 0000000..a782dee --- /dev/null +++ b/prolog/problems/sets/powerset_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'powerset/2' +slug = 'Poišči potenčno množico od dane množice' + +description = '''\ +

powerset(Set, Powerset): množica Powerset vsebuje vse podmnožice od množice Set.

+
+  ?- powerset([1,2,3], L).
+    L = [[1,2,3],[1,2],[1,3],[1],[2,3],[2],[3],[]].
+
''' + +hint = {} diff --git a/prolog/problems/sets/subset_2/sl.py b/prolog/problems/sets/subset_2/sl.py new file mode 100644 index 0000000..eae4fcf --- /dev/null +++ b/prolog/problems/sets/subset_2/sl.py @@ -0,0 +1,20 @@ +# coding=utf-8 + +name = 'subset/2' +slug = 'Generiraj vse podmnožice dane množice' + +description = '''\ +

subset(Set, Subset): množica Subset je podmnožica od Set. Ta predikat naj, eno po eno, generira vse veljavne podmnožice.

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

union(S1, S2, U): seznam U predstavlja unijo elementov v seznamih S1 in S2, duplikatov (kot se za množice spodobi) ni.

+
+  ?- union([1,5,2,3], [3,4,8,2], U).
+    U = [1,5,3,4,8,2].
+
''' + +hint = {} diff --git a/prolog/problems/sorting/is_sorted_1/sl.py b/prolog/problems/sorting/is_sorted_1/sl.py new file mode 100644 index 0000000..5d4c1c5 --- /dev/null +++ b/prolog/problems/sorting/is_sorted_1/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'is_sorted/1' +slug = 'Preveri, če so elementi seznama naraščajoče urejeni' + +description = '''\ +

is_sorted(L): elementi v seznamu L morajo biti urejeni v naraščajočem vrstnem redu.

+
+  ?- is_sorted([2,3,6,8,12]).
+    true.
+  ?- is_sorted([2,3,1,6,5]).
+    false.
+
''' + +hint = {} diff --git a/prolog/problems/sorting/isort_2/sl.py b/prolog/problems/sorting/isort_2/sl.py new file mode 100644 index 0000000..79c3239 --- /dev/null +++ b/prolog/problems/sorting/isort_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'isort/2' +slug = 'Uredi seznam z uporabo urejanja z vstavljanjem' + +description = '''\ +

isort(L, SL): seznam SL vsebuje elemente iz seznama L urejene v naraščajočem vrstnem redu. Uporabi predikat sins/3 za implementacijo urejanja z vstavljanjem.

+
+  ?- isort([2,3,1,5,4], L).
+    L = [1,2,3,4,5].
+
''' + +hint = {} diff --git a/prolog/problems/sorting/pivoting_4/sl.py b/prolog/problems/sorting/pivoting_4/sl.py new file mode 100644 index 0000000..b18e112 --- /dev/null +++ b/prolog/problems/sorting/pivoting_4/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'pivoting/4' +slug = 'Razdeli seznam na dva dela glede na podani element (pivot)' + +description = '''\ +

pivoting(P, L, S, G): seznam S vsebuje elemente iz L manjše ali enake P, seznam G pa elemente iz L večje od P. Vrstni red elementov v S in G naj bo enak kot v L.

+
+  ?- pivoting(4, [1,4,5,8,6,4,2], S, G).
+    S = [1,4,4,2], G = [5,8,6].
+
''' + +hint = {} diff --git a/prolog/problems/sorting/quick_sort_2/sl.py b/prolog/problems/sorting/quick_sort_2/sl.py new file mode 100644 index 0000000..9611b46 --- /dev/null +++ b/prolog/problems/sorting/quick_sort_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'quick_sort/2' +slug = 'Uredi seznam z algoritmom quicksort' + +description = '''\ +

quick_sort(L, SL): seznam SL vsebuje elemente iz L urejene v naraščajočem vrstnem redu. Uporabi predikat pivoting/4 za implementacijo algoritma quicksort.

+
+  ?- quick_sort([2,3,1,5,4], L).
+    L = [1,2,3,4,5].
+
''' + +hint = {} diff --git a/prolog/problems/sorting/sins_3/sl.py b/prolog/problems/sorting/sins_3/sl.py new file mode 100644 index 0000000..22e51b2 --- /dev/null +++ b/prolog/problems/sorting/sins_3/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'sins/3' +slug = 'Vstavi element na ustrezno mesto v urejen seznam' + +description = '''\ +

sins(X, SortedList, NewList): seznam NewList dobiš tako, da vstaviš element X v SortedList na ustrezno mesto tako, da ohraniš urejenost elementov.

+
+  ?- sins(4, [1,2,3,5], L).
+    L = [1,2,3,4,5].
+  ?- sins(3, [1,2,3,4], L).
+    L = [1,2,3,3,4].
+
''' + +hint = {} diff --git a/prolog/problems/sorting/slowest_sort_ever_2/sl.py b/prolog/problems/sorting/slowest_sort_ever_2/sl.py new file mode 100644 index 0000000..c62582c --- /dev/null +++ b/prolog/problems/sorting/slowest_sort_ever_2/sl.py @@ -0,0 +1,13 @@ +# coding=utf-8 + +name = 'slowest_sort_ever/2' +slug = 'Uredi seznam elementov s pomočjo naključnih permutacij' + +description = '''\ +

slowest_sort_ever(L, SL): seznam SL vsebuje elemente seznama L v naraščajočem vrstnem redu. Časovna zahtevnost algoritma naj bo O(n * n!).

+
+  ?- slowest_sort_ever([2,3,1,5,4], L).
+    L = [1,2,3,4,5].
+
''' + +hint = {} -- cgit v1.2.1 From 79f4196a6b86c6090ab0fb915d05bebc3a627783 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 14 Dec 2015 15:24:48 +0100 Subject: Add tests for Prolog.{sorting,sets,license_plates} --- .../license_plates/checklicenseplate_3/common.py | 44 ++++++++++++++++++ .../problems/license_plates/firstminus_2/common.py | 36 +++++++++++++++ prolog/problems/license_plates/genexp_2/common.py | 45 ++++++++++++++++++ .../problems/license_plates/getdigits_2/common.py | 38 +++++++++++++++ .../problems/license_plates/joindigits_2/common.py | 37 +++++++++++++++ prolog/problems/sets/diff_3/common.py | 44 ++++++++++++++++++ prolog/problems/sets/intersect_3/common.py | 44 ++++++++++++++++++ prolog/problems/sets/is_subset_2/common.py | 40 ++++++++++++++++ prolog/problems/sets/is_superset_2/common.py | 40 ++++++++++++++++ prolog/problems/sets/powerset_2/common.py | 38 +++++++++++++++ prolog/problems/sets/subset_2/common.py | 54 ++++++++++++++++++++++ prolog/problems/sets/union_3/common.py | 4 +- prolog/problems/sorting/is_sorted_1/common.py | 46 ++++++++++++++++++ prolog/problems/sorting/isort_2/common.py | 40 ++++++++++++++++ prolog/problems/sorting/pivoting_4/common.py | 40 ++++++++++++++++ prolog/problems/sorting/quick_sort_2/common.py | 40 ++++++++++++++++ prolog/problems/sorting/sins_3/common.py | 42 +++++++++++++++++ .../problems/sorting/slowest_sort_ever_2/common.py | 40 ++++++++++++++++ 18 files changed, 709 insertions(+), 3 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/license_plates/checklicenseplate_3/common.py b/prolog/problems/license_plates/checklicenseplate_3/common.py index c37e210..0480258 100644 --- a/prolog/problems/license_plates/checklicenseplate_3/common.py +++ b/prolog/problems/license_plates/checklicenseplate_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 148 number = 55 visible = True @@ -51,3 +55,43 @@ checkLicensePlate(LP, E1, E2) :- genexp148(MN2, E2), E1 =:= E2. ''' + +test_cases = [ + ('''checkLicensePlate([l, j, l, 3, '-', 2, 4, 2], E1, E2)''', + [{'E1': '-3', 'E2': '(-2-4)/2'}, {'E1': '3', 'E2': '(2+4)/2'}, + {'E1': '-3*2', 'E2': '-4-2'}, {'E1': '3*2', 'E2': '4+2'}, + {'E1': '-3*2+4', 'E2': '-2'}, {'E1': '3*2-4', 'E2': '2'}]), + ('''checkLicensePlate([k, r, a, 3, '-', 2, 1, 7], E1, E2)''', + [{'E1': '-3', 'E2': '-21/7'}, {'E1': '3', 'E2': '21/7'}, + {'E1': '-3*2', 'E2': '1-7'}, {'E1': '3*2', 'E2': '-1+7'}, + {'E1': '3*2+1', 'E2': '7'}, {'E1': '-3*2-1', 'E2': '-7'}]), + ('''checkLicensePlate([g, o, c, 8, '-', 2, 1, 3], E1, E2)''', + [{'E1': '-8', 'E2': '-2*(1+3)'}, {'E1': '8', 'E2': '2*(1+3)'}, + {'E1': '-8/2+1', 'E2': '-3'}, {'E1': '8/2-1', 'E2': '3'}, + {'E1': '-8/2', 'E2': '-1-3'}, {'E1': '8/2', 'E2': '1+3'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/license_plates/firstminus_2/common.py b/prolog/problems/license_plates/firstminus_2/common.py index 20376d2..89fe3b0 100644 --- a/prolog/problems/license_plates/firstminus_2/common.py +++ b/prolog/problems/license_plates/firstminus_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 147 number = 54 visible = True @@ -10,3 +14,35 @@ firstMinus(L, L). firstMinus([X|T], [Y|T]) :- Y is -X. ''' + +test_cases = [ + ('firstMinus([2, 3, 4], X)', + [{'X': '[2, 3, 4]'}, {'X': '[-2, 3, 4]'}]), + ('firstMinus([5, 2, 3, 4], X)', + [{'X': '[5, 2, 3, 4]'}, {'X': '[-5, 2, 3, 4]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/license_plates/genexp_2/common.py b/prolog/problems/license_plates/genexp_2/common.py index ecdc772..4b097f2 100644 --- a/prolog/problems/license_plates/genexp_2/common.py +++ b/prolog/problems/license_plates/genexp_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 146 number = 53 visible = True @@ -22,3 +26,44 @@ genexp(L, Exp) :- conc146(Before, [NExp|After], L1), genexp(L1, Exp). ''' + +test_cases = [ + ('genexp([1], X)', + [{'X': '1'}]), + ('genexp([1, 2], X)', + [{'X': '1*2'}, {'X': '1+2'}, {'X': '1-2'}, {'X': '1/2'}]), + ('genexp([1, 2, 3], X)', + [{'X': '1+2+3'}, {'X': '1+2-3'}, {'X': '(1+2)*3'}, {'X': '(1+2)/3'}, + {'X': '1-2+3'}, {'X': '1-2-3'}, {'X': '(1-2)*3'}, {'X': '(1-2)/3'}, + {'X': '1*2+3'}, {'X': '1*2-3'}, {'X': '1*2*3'}, {'X': '1*2/3'}, + {'X': '1/2+3'}, {'X': '1/2-3'}, {'X': '1/2*3'}, {'X': '1/2/3'}, + {'X': '1+(2+3)'}, {'X': '1-(2+3)'}, {'X': '1*(2+3)'}, {'X': '1/(2+3)'}, + {'X': '1+(2-3)'}, {'X': '1-(2-3)'}, {'X': '1*(2-3)'}, {'X': '1/(2-3)'}, + {'X': '1+2*3'}, {'X': '1-2*3'}, {'X': '1*(2*3)'}, {'X': '1/(2*3)'}, + {'X': '1+2/3'}, {'X': '1-2/3'}, {'X': '1*(2/3)'}, {'X': '1/(2/3)'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/license_plates/getdigits_2/common.py b/prolog/problems/license_plates/getdigits_2/common.py index 82fe033..4ae42ff 100644 --- a/prolog/problems/license_plates/getdigits_2/common.py +++ b/prolog/problems/license_plates/getdigits_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 144 number = 51 visible = True @@ -13,3 +17,37 @@ getdigits([X|T], [X|NT]) :- getdigits([_|T], NT) :- getdigits(T, NT). ''' + +test_cases = [ + ('getdigits([], X)', + [{'X': '[]'}]), + ('''getdigits([1, [], 2, a, b, -3, '+', 4], X)''', + [{'X': '[1, 2, -3, 4]'}]), + ('''getdigits([l, j, k, 3, '-', 2, 4, 2], X)''', + [{'X': '[3, 2, 4, 2]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/license_plates/joindigits_2/common.py b/prolog/problems/license_plates/joindigits_2/common.py index 9ebc037..189f221 100644 --- a/prolog/problems/license_plates/joindigits_2/common.py +++ b/prolog/problems/license_plates/joindigits_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 145 number = 52 visible = True @@ -13,3 +17,36 @@ joindigits([X,Y|T], NT) :- joindigits([X,Y|T], [X|NT]) :- joindigits([Y|T], NT). ''' + +test_cases = [ + ('joindigits([2, 3, 1, 4], X)', + [{'X': '[2, 3, 1, 4]'}, {'X': '[2, 3, 14]'}, {'X': '[2, 31, 4]'}, {'X': '[2, 314]'}, + {'X': '[23, 1, 4]'}, {'X': '[23, 14]'}, {'X': '[231, 4]'}, {'X': '[2314]'}]), + ('joindigits([2, 3, 1], X)', + [{'X': '[2, 3, 1]'}, {'X': '[2, 31]'}, {'X': '[23, 1]'}, {'X': '[231]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/diff_3/common.py b/prolog/problems/sets/diff_3/common.py index fee93b2..e2706cb 100644 --- a/prolog/problems/sets/diff_3/common.py +++ b/prolog/problems/sets/diff_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 130 number = 37 visible = True @@ -18,3 +22,43 @@ diff([H|T], S2, D) :- memb130(H, S2), diff(T, S2, D). ''' + +test_cases = [ + ('diff([], [t, e, q], X)', + [{'X': '[]'}]), + ('diff([q, r, t], [], A), msort(A, X)', + [{'X': '[q, r, t]'}]), + ('diff([1, 2, 3, 8, 4, 6], [6, 0, 3, 4], A), msort(A, X)', + [{'X': '[1, 2, 8]'}]), + ('diff([1, 2, 3, 8, 7, 4, 6], [7, 8, 6], A), msort(A, X)', + [{'X': '[1, 2, 3, 4]'}]), + ('diff([1, 8, 2, 3, 7, 5], [7], A), msort(A, X)', + [{'X': '[1, 2, 3, 5, 8]'}]), + ('diff([t, w, q], [t, e, q, w, b], X)', + [{'X': '[]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/intersect_3/common.py b/prolog/problems/sets/intersect_3/common.py index 501cdf3..ba90db7 100644 --- a/prolog/problems/sets/intersect_3/common.py +++ b/prolog/problems/sets/intersect_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 129 number = 36 visible = True @@ -17,3 +21,43 @@ intersect([H|T], S2, [H|I]) :- intersect([_|T], S2, I):- intersect(T, S2, I). ''' + +test_cases = [ + ('intersect([], [a, b, d], X)', + [{'X': '[]'}]), + ('intersect([g, h, r], [], X)', + [{'X': '[]'}]), + ('intersect([2, 5, 4, 7, 1, 9, 8], [0, 2, 5, 6, 7, 9, 1], A), msort(A, X)', + [{'X': '[1, 2, 5, 7, 9]'}]), + ('intersect([4, 7, 1, 9, 8], [4, 2, 5, 6, 7, 9, 1], A), msort(A, X)', + [{'X': '[1, 4, 7, 9]'}]), + ('intersect([9, 3, 4, 2, 1, 7], [a, b, d], X)', + [{'X': '[]'}]), + ('intersect([9, 3, 4, 2, 1, 7], [4, 2, 5, 6, 7, 9, 1], A), msort(A, X)', + [{'X': '[1, 2, 4, 7, 9]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/is_subset_2/common.py b/prolog/problems/sets/is_subset_2/common.py index 4047146..a64d0f8 100644 --- a/prolog/problems/sets/is_subset_2/common.py +++ b/prolog/problems/sets/is_subset_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 132 number = 39 visible = True @@ -15,3 +19,39 @@ is_subset([H|T], S2) :- memb132(H, S2), is_subset(T, S2). ''' + +test_cases = [ + ('is_subset(X, [])', + [{'X': '[]'}]), + ('is_subset([2, 1, 3], [3, 2, 1, 4, 6, 7])', + [{}]), + ('\+ is_subset([2, 1, 0, 3], [3, 2, 1, 4, 6, 7])', + [{}]), + ('is_subset([3, 2, 1, 4, 6, 7], [3, 2, 1, 4, 6, 7])', + [{}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/is_superset_2/common.py b/prolog/problems/sets/is_superset_2/common.py index 86e5dc7..abd3cfb 100644 --- a/prolog/problems/sets/is_superset_2/common.py +++ b/prolog/problems/sets/is_superset_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 131 number = 38 visible = True @@ -15,3 +19,39 @@ is_superset(S1, [H|T]) :- memb131(H, S1), is_superset(S1, T). ''' + +test_cases = [ + ('is_superset([], X)', + [{'X': '[]'}]), + ('is_superset([3, 2, 1, 4, 6, 7], [2, 1, 3])', + [{}]), + ('\+ is_superset([3, 2, 1, 4, 6, 7], [2, 1, 0, 3])', + [{}]), + ('is_superset([3, 2, 1, 4, 6, 7], [3, 2, 1, 4, 6, 7])', + [{}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/powerset_2/common.py b/prolog/problems/sets/powerset_2/common.py index c825430..77801d7 100644 --- a/prolog/problems/sets/powerset_2/common.py +++ b/prolog/problems/sets/powerset_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 134 number = 41 visible = True @@ -15,3 +19,37 @@ subset134([_|T], T1) :- powerset(Set, PowerSet) :- findall(S, subset134(Set, S), PowerSet). ''' + +test_cases = [ + ('powerset([], X)', + [{'X': '[[]]'}]), + ('powerset([1, 2], A), length(A, 4), lists:flatten(A, Y), msort(Y, X)', + [{'X': '[1, 1, 2, 2]'}]), + ('powerset([1, 2, 3], A), length(A, 8), lists:flatten(A, Y), msort(Y, X)', + [{'X': '[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/subset_2/common.py b/prolog/problems/sets/subset_2/common.py index 130d87b..99d0799 100644 --- a/prolog/problems/sets/subset_2/common.py +++ b/prolog/problems/sets/subset_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 133 number = 40 visible = True @@ -12,3 +16,53 @@ subset([H|T], [H|T1]) :- subset([_|T], T1) :- subset(T, T1). ''' + +test_cases = [ + ('subset([], X)', + [{'X': '[]'}]), + ('subset([1, 3, 5, 7], A), msort(A, X)', + [{'X': '[]'}, {'X': '[7]'}, {'X': '[5]'}, {'X': '[5, 7]'}, {'X': '[3]'}, + {'X': '[3, 7]'}, {'X': '[3, 5]'}, {'X': '[3, 5, 7]'}, {'X': '[1]'}, + {'X': '[1, 7]'}, {'X': '[1, 5]'}, {'X': '[1, 5, 7]'}, {'X': '[1, 3]'}, + {'X': '[1, 3, 7]'}, {'X': '[1, 3, 5]'}, {'X': '[1, 3, 5, 7]'}]), + ('subset([8, 4, 6, 2], A), msort(A, X)', + [{'X': '[]'}, {'X': '[2]'}, {'X': '[6]'}, {'X': '[2, 6]'}, {'X': '[4]'}, + {'X': '[2, 4]'}, {'X': '[4, 6]'}, {'X': '[2, 4, 6]'}, {'X': '[8]'}, + {'X': '[2, 8]'}, {'X': '[6, 8]'}, {'X': '[2, 6, 8]'}, {'X': '[4, 8]'}, + {'X': '[2, 4, 8]'}, {'X': '[4, 6, 8]'}, {'X': '[2, 4, 6, 8]'}]), + ('subset([5, 6, 7, 0, 2], A), msort(A, X)', + [{'X': '[]'}, {'X': '[2]'}, {'X': '[0]'}, {'X': '[0, 2]'}, {'X': '[7]'}, + {'X': '[2, 7]'}, {'X': '[0, 7]'}, {'X': '[0, 2, 7]'}, {'X': '[6]'}, + {'X': '[2, 6]'}, {'X': '[0, 6]'}, {'X': '[0, 2, 6]'}, {'X': '[6, 7]'}, + {'X': '[2, 6, 7]'}, {'X': '[0, 6, 7]'}, {'X': '[0, 2, 6, 7]'}, + {'X': '[5]'}, {'X': '[2, 5]'}, {'X': '[0, 5]'}, {'X': '[0, 2, 5]'}, + {'X': '[5, 7]'}, {'X': '[2, 5, 7]'}, {'X': '[0, 5, 7]'}, + {'X': '[0, 2, 5, 7]'}, {'X': '[5, 6]'}, {'X': '[2, 5, 6]'}, + {'X': '[0, 5, 6]'}, {'X': '[0, 2, 5, 6]'}, {'X': '[5, 6, 7]'}, + {'X': '[2, 5, 6, 7]'}, {'X': '[0, 5, 6, 7]'}, {'X': '[0, 2, 5, 6, 7]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sets/union_3/common.py b/prolog/problems/sets/union_3/common.py index 506913a..774c8cf 100644 --- a/prolog/problems/sets/union_3/common.py +++ b/prolog/problems/sets/union_3/common.py @@ -45,9 +45,7 @@ def test(program, solved_problems): 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/sorting/is_sorted_1/common.py b/prolog/problems/sorting/is_sorted_1/common.py index 8feb549..9213ddc 100644 --- a/prolog/problems/sorting/is_sorted_1/common.py +++ b/prolog/problems/sorting/is_sorted_1/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 121 number = 28 visible = True @@ -12,3 +16,45 @@ is_sorted([H1,H2|T]) :- H1 =< H2, is_sorted([H2|T]). ''' + +test_cases = [ + ('is_sorted([])', + [{}]), + ('is_sorted([5, 6, 13, 555, 2111, 2112])', + [{}]), + ('is_sorted([2, 5, 5, 13, 555, 2111, 2112])', + [{}]), + ('is_sorted([-2])', + [{}]), + ('is_sorted([-42, -42, -42, -42])', + [{}]), + ('\+ is_sorted([3, 4, 5, 6, 1, 2, 3])', + [{}]), + ('\+ is_sorted([3, 4, 5, 6, 1, 2, 3, 0])', + [{}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sorting/isort_2/common.py b/prolog/problems/sorting/isort_2/common.py index f2c4244..6041b35 100644 --- a/prolog/problems/sorting/isort_2/common.py +++ b/prolog/problems/sorting/isort_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 123 number = 30 visible = True @@ -17,3 +21,39 @@ isort([H|T], SL) :- isort(T, ST), sins123(H, ST, SL). ''' + +test_cases = [ + ('isort([], X)', + [{'X': '[]'}]), + ('isort([5, 3, 5, 5, 1, 2, 0], X)', + [{'X': '[0, 1, 2, 3, 5, 5, 5]'}]), + ('isort([2, 1, 3, 5, 6, 0, 22, 3], X)', + [{'X': '[0, 1, 2, 3, 3, 5, 6, 22]'}]), + ('isort([5, 4, 3, 2, 1], X)', + [{'X': '[1, 2, 3, 4, 5]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sorting/pivoting_4/common.py b/prolog/problems/sorting/pivoting_4/common.py index dd1a1a9..0e9afaa 100644 --- a/prolog/problems/sorting/pivoting_4/common.py +++ b/prolog/problems/sorting/pivoting_4/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 124 number = 31 visible = True @@ -14,3 +18,39 @@ pivoting(P, [H|T], S, [H|G]) :- H > P, pivoting(P, T, S, G). ''' + +test_cases = [ + ('pivoting(5, [], A, B)', + [{'A': '[]', 'B': '[]'}]), + ('pivoting(5, [6, 7, 6], A, B)', + [{'A': '[]', 'B': '[6, 7, 6]'}]), + ('pivoting(4, [2, 1, 8, 9, 3, 4, 2], A, B)', + [{'A': '[2, 1, 3, 4, 2]', 'B': '[8, 9]'}]), + ('pivoting(4, [22, 1, 0, 8, 3, 5, 7, -2], A, B)', + [{'A': '[1, 0, 3, -2]', 'B': '[22, 8, 5, 7]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sorting/quick_sort_2/common.py b/prolog/problems/sorting/quick_sort_2/common.py index 4afc8fa..b1449f1 100644 --- a/prolog/problems/sorting/quick_sort_2/common.py +++ b/prolog/problems/sorting/quick_sort_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 125 number = 32 visible = True @@ -23,3 +27,39 @@ quick_sort([Pivot|T], Sorted) :- quick_sort(Greater, SortedGreater), conc125(SortedSmaller, [Pivot|SortedGreater], Sorted). ''' + +test_cases = [ + ('quick_sort([], X)', + [{'X': '[]'}]), + ('quick_sort([5, 3, 5, 5, 1, 2, 0], X)', + [{'X': '[0, 1, 2, 3, 5, 5, 5]'}]), + ('quick_sort([2, 1, 3, 5, 6, 0, 22, 3], X)', + [{'X': '[0, 1, 2, 3, 3, 5, 6, 22]'}]), + ('quick_sort([5, 4, 3, 2, 1], X)', + [{'X': '[1, 2, 3, 4, 5]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sorting/sins_3/common.py b/prolog/problems/sorting/sins_3/common.py index ab592ea..4c707ca 100644 --- a/prolog/problems/sorting/sins_3/common.py +++ b/prolog/problems/sorting/sins_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 122 number = 29 visible = True @@ -13,3 +17,41 @@ sins(X, [Y|T], [Y|L]) :- X > Y, sins(X, T, L). ''' + +test_cases = [ + ('sins(4, [], X)', + [{'X': '[4]'}]), + ('sins(4, [1, 2, 5, 6, 8], X)', + [{'X': '[1, 2, 4, 5, 6, 8]'}]), + ('sins(8, [1, 2, 3, 4, 5, 6, 7], X)', + [{'X': '[1, 2, 3, 4, 5, 6, 7, 8]'}]), + ('sins(1, [2, 3, 4, 5, 6, 7], X)', + [{'X': '[1, 2, 3, 4, 5, 6, 7]'}]), + ('sins(2, [2, 3, 4, 5, 6, 7], X)', + [{'X': '[2, 2, 3, 4, 5, 6, 7]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/sorting/slowest_sort_ever_2/common.py b/prolog/problems/sorting/slowest_sort_ever_2/common.py index fc8f980..72e25e2 100644 --- a/prolog/problems/sorting/slowest_sort_ever_2/common.py +++ b/prolog/problems/sorting/slowest_sort_ever_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 126 number = 33 visible = True @@ -24,3 +28,39 @@ slowest_sort_ever(L, S) :- permute126(L, S), is_sorted126(S). ''' + +test_cases = [ + ('slowest_sort_ever([], X)', + [{'X': '[]'}]), + ('slowest_sort_ever([5, 3, 5, 1], X)', + [{'X': '[1, 3, 5, 5]'}]), + ('slowest_sort_ever([2, 1, 5, 6], X)', + [{'X': '[1, 2, 5, 6]'}]), + ('slowest_sort_ever([5, 4, 3, 2], X)', + [{'X': '[2, 3, 4, 5]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] -- cgit v1.2.1 From 0aa5a6d59744727f8f486f35f1501aab87e4c529 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 14 Dec 2015 20:38:58 +0100 Subject: Add test function for prolog.clp_fd.puzzle_beth --- prolog/problems/clp_fd/puzzle_beth_1/common.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'prolog/problems') diff --git a/prolog/problems/clp_fd/puzzle_beth_1/common.py b/prolog/problems/clp_fd/puzzle_beth_1/common.py index bf81396..8a975ee 100644 --- a/prolog/problems/clp_fd/puzzle_beth_1/common.py +++ b/prolog/problems/clp_fd/puzzle_beth_1/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 155 number = 56 visible = True @@ -8,3 +12,35 @@ facts = None solution = '''\ puzzle_beth(X) :- X + 2 #= 2*(X-5).''' + +test_cases = [ + ('puzzle_beth(X)', + [{'X': '12'}]), + ('setof(A, puzzle_beth(A), X)', + [{'X': '[12]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] -- cgit v1.2.1 From 2f3e3b67592de852917aa3e32e76d9060d17fdf8 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Mon, 14 Dec 2015 23:19:19 +0100 Subject: Test cases for CLPFD, and Slovenian translations for CLPFD and DCG added. --- prolog/problems/clp_fd/tobase_3/common.py | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'prolog/problems') diff --git a/prolog/problems/clp_fd/tobase_3/common.py b/prolog/problems/clp_fd/tobase_3/common.py index 5d160d7..5e3a783 100644 --- a/prolog/problems/clp_fd/tobase_3/common.py +++ b/prolog/problems/clp_fd/tobase_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 150 number = 62 visible = True @@ -14,3 +18,45 @@ tobase(N, B, Nb) :- Rem #>= 0, Rem #< B, Nb #= Nb1 * 10 + Rem, tobase(N1, B, Nb1).''' + +test_cases = [ + ('tobase(214, 2, X)', + [{'X': '11010110'}]), + ('tobase(321, 7, X)', + [{'X': '636'}]), + ('tobase(X, 8, 777)', + [{'X': '511'}]), + ('tobase(X, 8, 132)', + [{'X': '90'}]), + ('tobase(653, X, 10103)', + [{'X': '5'}]), + ('tobase(123, X, 146)', + [{'X': '9'}]), + ('setof(B/N, tobase(123, B, N), X)', + [{'X': '[2/1111011, 3/11120, 4/1323, 5/443, 6/323, 7/234, 8/173, 9/146, 10/123]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] -- cgit v1.2.1 From f22468b134a88fcd7acb1415c9997f578f1abe7b Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Tue, 15 Dec 2015 10:44:52 +0100 Subject: Add tests for Prolog.clp_fd --- prolog/problems/clp_fd/gcd_3/common.py | 44 ++++++++++++++++++++++++ prolog/problems/clp_fd/magic_1/common.py | 41 ++++++++++++++++++++++ prolog/problems/clp_fd/puzzle_abc_3/common.py | 36 +++++++++++++++++++ prolog/problems/clp_fd/puzzle_momson_2/common.py | 38 ++++++++++++++++++++ prolog/problems/clp_fd/puzzle_ratio_2/common.py | 36 +++++++++++++++++++ 5 files changed, 195 insertions(+) (limited to 'prolog/problems') diff --git a/prolog/problems/clp_fd/gcd_3/common.py b/prolog/problems/clp_fd/gcd_3/common.py index 7cd6623..6e62e3b 100644 --- a/prolog/problems/clp_fd/gcd_3/common.py +++ b/prolog/problems/clp_fd/gcd_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 149 number = 61 visible = True @@ -15,3 +19,43 @@ gcd(X, Y, GCD):- cd(X, Y, GCD), \+ ( cd(X, Y, CD), CD > GCD ). ''' + +test_cases = [ + ('gcd(1, 1, X)', + [{'X': '1'}]), + ('gcd(12, 8, X)', + [{'X': '4'}]), + ('gcd(18, 36, X)', + [{'X': '18'}]), + ('gcd(21, 14, X)', + [{'X': '7'}]), + ('gcd(10, 22, X)', + [{'X': '2'}]), + ('gcd(66, 60, X)', + [{'X': '6'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/clp_fd/magic_1/common.py b/prolog/problems/clp_fd/magic_1/common.py index 17a9199..b897cb3 100644 --- a/prolog/problems/clp_fd/magic_1/common.py +++ b/prolog/problems/clp_fd/magic_1/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 151 number = 60 visible = True @@ -16,3 +20,40 @@ magic(L):- A1+B1+C1 #= A3+B3+C3, A1+B2+C3 #= A3+B2+C1, labeling([], L).''' + +test_cases = [ + ('magic(X)', + [{'X': '[2, 7, 6, 9, 5, 1, 4, 3, 8]'}]), + ('magic(X)', + [{'X': '[2, 9, 4, 7, 5, 3, 6, 1, 8]'}]), + ('setof(S, magic(S), X)', + [{'X': '[[2, 7, 6, 9, 5, 1, 4, 3, 8], [2, 9, 4, 7, 5, 3, 6, 1, 8], \ + [4, 3, 8, 9, 5, 1, 2, 7, 6], [4, 9, 2, 3, 5, 7, 8, 1, 6], \ + [6, 1, 8, 7, 5, 3, 2, 9, 4], [6, 7, 2, 1, 5, 9, 8, 3, 4], \ + [8, 1, 6, 3, 5, 7, 4, 9, 2], [8, 3, 4, 1, 5, 9, 6, 7, 2]]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/clp_fd/puzzle_abc_3/common.py b/prolog/problems/clp_fd/puzzle_abc_3/common.py index 1563e1f..34ad409 100644 --- a/prolog/problems/clp_fd/puzzle_abc_3/common.py +++ b/prolog/problems/clp_fd/puzzle_abc_3/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 153 number = 57 visible = True @@ -13,3 +17,35 @@ puzzle_abc(A, B, C) :- [A,B,C] ins 0..inf, labeling([], [A,B,C]). ''' + +test_cases = [ + ('puzzle_abc(A, B, C)', + [{'A': '12', 'B': '10', 'C': '5'}]), + ('setof(A/B/C, puzzle_abc(A, B, C), X)', + [{'X': '[12/10/5]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/clp_fd/puzzle_momson_2/common.py b/prolog/problems/clp_fd/puzzle_momson_2/common.py index 9cef246..0f9e0a8 100644 --- a/prolog/problems/clp_fd/puzzle_momson_2/common.py +++ b/prolog/problems/clp_fd/puzzle_momson_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 152 number = 58 visible = True @@ -13,3 +17,37 @@ puzzle_momson(M, S) :- M + S #= 66, M #> S, labeling([], [M, S]).''' + +test_cases = [ + ('puzzle_momson(M, S)', + [{'M': '42', 'S': '24'}]), + ('puzzle_momson(M, S)', + [{'M': '51', 'S': '15'}]), + ('setof(M/S, puzzle_momson(M, S), X)', + [{'X': '[42/24, 51/15]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] diff --git a/prolog/problems/clp_fd/puzzle_ratio_2/common.py b/prolog/problems/clp_fd/puzzle_ratio_2/common.py index 73b9234..eca7f62 100644 --- a/prolog/problems/clp_fd/puzzle_ratio_2/common.py +++ b/prolog/problems/clp_fd/puzzle_ratio_2/common.py @@ -1,5 +1,9 @@ # coding=utf-8 +from operator import itemgetter +import prolog.engine +import server.problems + id = 154 number = 59 visible = True @@ -16,3 +20,35 @@ puzzle_ratio(A, B) :- A #< 200, B #< 200, labeling([], [A, B]).''' + +test_cases = [ + ('puzzle_ratio(A, B)', + [{'A': '30', 'B': '24'}]), + ('setof(A/B, puzzle_ratio(A, B), X)', + [{'X': '[30/24]'}]), +] + +def test(program, solved_problems): + code = (program + '\n' + + server.problems.solutions_for_problems('prolog', solved_problems)) + + n_correct = 0 + engine_id = None + try: + engine_id, output = prolog.engine.create(code=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: + if prolog.engine.check_answers(engine_id, query=query, answers=answers, timeout=1.0): + n_correct += 1 + finally: + if engine_id: + prolog.engine.destroy(engine_id) + + passed = n_correct == len(test_cases) + hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_cases)}}] + return passed, hints + +def hint(program, solved_problems): + # TODO + return [] -- cgit v1.2.1 From 2a4a1d39bfcfb8b258be96c180dde09a12345295 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Tue, 15 Dec 2015 10:45:30 +0100 Subject: Add Slovenian translations for Prolog.{clp_fd,dcg} --- prolog/problems/clp_fd/gcd_3/sl.py | 14 ++++++++++++++ prolog/problems/clp_fd/magic_1/sl.py | 14 ++++++++++++++ prolog/problems/clp_fd/puzzle_abc_3/sl.py | 10 ++++++++++ prolog/problems/clp_fd/puzzle_beth_1/sl.py | 11 +++++++++++ prolog/problems/clp_fd/puzzle_momson_2/sl.py | 10 ++++++++++ prolog/problems/clp_fd/puzzle_ratio_2/sl.py | 10 ++++++++++ prolog/problems/clp_fd/tobase_3/sl.py | 17 +++++++++++++++++ prolog/problems/dcg/ab_2/sl.py | 11 +++++++++++ prolog/problems/dcg/digit_2/sl.py | 9 +++++++++ prolog/problems/dcg/expr_2/sl.py | 11 +++++++++++ prolog/problems/dcg/expr_3/sl.py | 15 +++++++++++++++ prolog/problems/dcg/flower_2/sl.py | 11 +++++++++++ prolog/problems/dcg/number_2/sl.py | 10 ++++++++++ prolog/problems/dcg/number_3/sl.py | 14 ++++++++++++++ prolog/problems/dcg/number_proper_2/sl.py | 10 ++++++++++ prolog/problems/dcg/paren_2/sl.py | 11 +++++++++++ prolog/problems/dcg/paren_3/sl.py | 14 ++++++++++++++ 17 files changed, 202 insertions(+) create mode 100644 prolog/problems/clp_fd/gcd_3/sl.py create mode 100644 prolog/problems/clp_fd/magic_1/sl.py create mode 100644 prolog/problems/clp_fd/puzzle_abc_3/sl.py create mode 100644 prolog/problems/clp_fd/puzzle_beth_1/sl.py create mode 100644 prolog/problems/clp_fd/puzzle_momson_2/sl.py create mode 100644 prolog/problems/clp_fd/puzzle_ratio_2/sl.py create mode 100644 prolog/problems/clp_fd/tobase_3/sl.py create mode 100644 prolog/problems/dcg/ab_2/sl.py create mode 100644 prolog/problems/dcg/digit_2/sl.py create mode 100644 prolog/problems/dcg/expr_2/sl.py create mode 100644 prolog/problems/dcg/expr_3/sl.py create mode 100644 prolog/problems/dcg/flower_2/sl.py create mode 100644 prolog/problems/dcg/number_2/sl.py create mode 100644 prolog/problems/dcg/number_3/sl.py create mode 100644 prolog/problems/dcg/number_proper_2/sl.py create mode 100644 prolog/problems/dcg/paren_2/sl.py create mode 100644 prolog/problems/dcg/paren_3/sl.py (limited to 'prolog/problems') diff --git a/prolog/problems/clp_fd/gcd_3/sl.py b/prolog/problems/clp_fd/gcd_3/sl.py new file mode 100644 index 0000000..9ef1a87 --- /dev/null +++ b/prolog/problems/clp_fd/gcd_3/sl.py @@ -0,0 +1,14 @@ +# coding=utf-8 + +name = 'gcd/3' +slug = 'Največji skupni delitelj' + +description = '''\ +

gcd(X, Y, GCD): GCD je največji skupni delitelj števil X in Y. Implementiraj ta predikat z uporabo omejitev.

+

Namig: poskusi najprej napisati predikat, ki poišče vse skupne delitelje dveh števil.

+
+  ?- gcd(36, 84, GCD).
+    GCD = 12.
+
''' + +hint = {} diff --git a/prolog/problems/clp_fd/magic_1/sl.py b/prolog/problems/clp_fd/magic_1/sl.py new file mode 100644 index 0000000..8cf040e --- /dev/null +++ b/prolog/problems/clp_fd/magic_1/sl.py @@ -0,0 +1,14 @@ +# coding=utf-8 + +name = 'magic/1' +slug = '3x3 magični kvadrat' + +description = '''\ +

magic(S): seznam S predstavlja 3×3 magični kvadrat (S je permutacija števil 1 do 9 -- tri števila tvorijo eno vrstico). Vsote števil v vsaki vrstici, stolpcu in glavni diagonali magičnega kvadrata so enake. Implementiraj ta predikat z uporabo omejitev. Predikat naj vrne vse rešitve, eno po eno.

+
+  ?- magic(S).
+    S = [2, 7, 6, 9, 5, 1, 4, 3, 8] ;
+    …
+
''' + +hint = {} diff --git a/prolog/problems/clp_fd/puzzle_abc_3/sl.py b/prolog/problems/clp_fd/puzzle_abc_3/sl.py new file mode 100644 index 0000000..118481a --- /dev/null +++ b/prolog/problems/clp_fd/puzzle_abc_3/sl.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +name = 'puzzle_abc/3' +slug = 'Uganka z leti: ABC' + +description = '''\ +

Oseba A je dve leti starejša od osebe B, ki je dvakrat starejša od osebe C. Skupaj so osebe A, B in C stare 27 let.

+

Napiši predikat puzzle_abc(A, B, C), ki izračuna koliko so stare osebe A, B in C.

''' + +hint = {} diff --git a/prolog/problems/clp_fd/puzzle_beth_1/sl.py b/prolog/problems/clp_fd/puzzle_beth_1/sl.py new file mode 100644 index 0000000..261ec74 --- /dev/null +++ b/prolog/problems/clp_fd/puzzle_beth_1/sl.py @@ -0,0 +1,11 @@ +# coding=utf-8 + +name = 'puzzle_beth/1' +slug = 'Uganka z leti: Beti' + +description = '''\ +

Ko so Beti vprašali koliko je stara, je odgovorila takole "Čez dve leti bom dvakrat starejša kot sem bila pet let nazaj".

+

Napiši predikat puzzle_beth(X), ki izračuna njeno trenutno starost X.

+''' + +hint = {} diff --git a/prolog/problems/clp_fd/puzzle_momson_2/sl.py b/prolog/problems/clp_fd/puzzle_momson_2/sl.py new file mode 100644 index 0000000..593f153 --- /dev/null +++ b/prolog/problems/clp_fd/puzzle_momson_2/sl.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +name = 'puzzle_momson/2' +slug = 'Uganka z leti: mama in sin' + +description = '''\ +

Mama in sin sta skupaj stara 66 let. Mamina leta so ravno sinova obrnjena leta (obrnjene so cifre). Koliko sta stara?

+

Napiši predikat puzzle_momson(M, S), ki izračuna starost mame M in sina S.

''' + +hint = {} diff --git a/prolog/problems/clp_fd/puzzle_ratio_2/sl.py b/prolog/problems/clp_fd/puzzle_ratio_2/sl.py new file mode 100644 index 0000000..826e66f --- /dev/null +++ b/prolog/problems/clp_fd/puzzle_ratio_2/sl.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +name = 'puzzle_ratio/2' +slug = 'Uganka z leti: razmerje' + +description = '''\ +

Trenutni starosti osebe A in osebe B sta v razmerju 5:4. Čez tri leta bo razmerje njunih let postalo 11:9.

+

Napiši predikat puzzle_ratio(A, B), ki izračuna starost osebe A in osebe B.

''' + +hint = {} diff --git a/prolog/problems/clp_fd/tobase_3/sl.py b/prolog/problems/clp_fd/tobase_3/sl.py new file mode 100644 index 0000000..a775808 --- /dev/null +++ b/prolog/problems/clp_fd/tobase_3/sl.py @@ -0,0 +1,17 @@ +# coding=utf-8 + +name = 'tobase/3' +slug = 'Pretvori števila v/iz desetiškega sistema' + +description = '''\ +

tobase(Number, B, X): število Number je v desetiškem sistemu. X predstavlja to število v sistemu z bazo B. Implementiraj predikat z uporabo omejitev. Omeji vrednost B na interval [2..10].

+
+  ?- tobase(42, 2, X).
+    X = 101010.
+  ?- tobase(N, 2, 101010).
+    N = 42.
+  ?- tobase(42, B, 101010).
+    B = 2.
+
''' + +hint = {} diff --git a/prolog/problems/dcg/ab_2/sl.py b/prolog/problems/dcg/ab_2/sl.py new file mode 100644 index 0000000..d2d8924 --- /dev/null +++ b/prolog/problems/dcg/ab_2/sl.py @@ -0,0 +1,11 @@ +# coding=utf-8 + +name = 'ab/2' +slug = 'a*b*' + +description = '''\ +

Napiši DCG gramatiko z začetnim simbolom ab za jezik ambn, kjer sta m, n ≥ 0.

+

Primeri veljavnih besed: [], a, aab, abbb, bbb.

+

Namig: za generiranje vedno daljših besed uporabi poizvedbo conc(Word,_,_), ab(Word,[]).

''' + +hint = {} diff --git a/prolog/problems/dcg/digit_2/sl.py b/prolog/problems/dcg/digit_2/sl.py new file mode 100644 index 0000000..393e0e1 --- /dev/null +++ b/prolog/problems/dcg/digit_2/sl.py @@ -0,0 +1,9 @@ +# coding=utf-8 + +name = 'digit/2' +slug = 'Cifra' + +description = '''\ +

Napiši gramatiko z začetnim simbolom digit za jezik definiran z naslednjo množico: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.

''' + +hint = {} diff --git a/prolog/problems/dcg/expr_2/sl.py b/prolog/problems/dcg/expr_2/sl.py new file mode 100644 index 0000000..6401deb --- /dev/null +++ b/prolog/problems/dcg/expr_2/sl.py @@ -0,0 +1,11 @@ +# coding=utf-8 + +name = 'expr/2' +slug = 'Aritmetični izrazi' + +description = '''\ +

Napiši gramatiko z začetnim simbolom expr za jezik aritmetičnih izrazov, ki vsebujejo števila (brez vodilnih ničel), vsoto in množenje. Podizrazi se lahko združujejo z oklepaji.

+

Primeri veljavnih besed: (1+2)*3, 42*8*3, (2+1)*(3+4).

+''' + +hint = {} diff --git a/prolog/problems/dcg/expr_3/sl.py b/prolog/problems/dcg/expr_3/sl.py new file mode 100644 index 0000000..734a6ea --- /dev/null +++ b/prolog/problems/dcg/expr_3/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'expr/3' +slug = 'Aritmetični izrazi s pomenom' + +description = '''\ +

Napiši gramatiko z začetnim simbolom expr za jezik aritmetičnih izrazov, ki vsebujejo števila (brez vodilnih ničel), vsoto in množenje. Podizrazi se lahko združujejo z oklepaji. Pomen besede v tem jeziku je numerična vrednost predstavljenega izraza.

+

Primeri veljavnih besed: (1+2)*3, 42*8*3, (2+1)*(3+4).

+
+  ?- expr(N, ['(',2,'+',1,')','*','(',3,'+',4,')'], []).  % (2+1)*(3+4) = 21
+    N = 21.
+
+''' + +hint = {} diff --git a/prolog/problems/dcg/flower_2/sl.py b/prolog/problems/dcg/flower_2/sl.py new file mode 100644 index 0000000..30e4118 --- /dev/null +++ b/prolog/problems/dcg/flower_2/sl.py @@ -0,0 +1,11 @@ +# coding=utf-8 + +name = 'flower/2' +slug = 'Besede v obliki "rožice", npr. +++--+++' + +description = '''\ +

Napiši gramatiko z začetnim simbolom flower za jezik +n-m+n, kjer je m > 0 in n ≥ 0.

+

Primeri veljavnih besed: -, ++-++, +---+.

+''' + +hint = {} diff --git a/prolog/problems/dcg/number_2/sl.py b/prolog/problems/dcg/number_2/sl.py new file mode 100644 index 0000000..cdcbcee --- /dev/null +++ b/prolog/problems/dcg/number_2/sl.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +name = 'number/2' +slug = 'Števila z dovoljenimi vodilnimi ničlami' + +description = '''\ +

Napiši gramatiko z začetnim simbolom number za jezik nenegativnih celih števil. Števila lahko vsebujejo vodilne ničle.

+

Primeri veljavnih besed: 123, 54, 0122, 0001221, 0.

''' + +hint = {} diff --git a/prolog/problems/dcg/number_3/sl.py b/prolog/problems/dcg/number_3/sl.py new file mode 100644 index 0000000..eeb4db2 --- /dev/null +++ b/prolog/problems/dcg/number_3/sl.py @@ -0,0 +1,14 @@ +# coding=utf-8 + +name = 'number/3' +slug = 'Števila s pomenom' + +description = '''\ +

Napiši gramatiko z začetnim simbolom number za jezik nenegativnih celih števil. Števila lahko vsebujejo vodilne ničle. Pomen besede v tem jeziku je kar numerična vrednost predstavljenega števila.

+
+  ?- number(N, [1,2,3,4], []).
+    N = 1234.
+
+''' + +hint = {} diff --git a/prolog/problems/dcg/number_proper_2/sl.py b/prolog/problems/dcg/number_proper_2/sl.py new file mode 100644 index 0000000..1b39977 --- /dev/null +++ b/prolog/problems/dcg/number_proper_2/sl.py @@ -0,0 +1,10 @@ +# coding=utf-8 + +name = 'number_proper/2' +slug = 'Števila brez vodilnih ničel' + +description = '''\ +

Napiši gramatiko z začetnim simbolom number za jezik nenegativnih celih števil. Števila ne smejo vsebovati vodilnih ničel.

+

Primeri veljavnih besed: 123, 54, 122, 1221, 0.

''' + +hint = {} diff --git a/prolog/problems/dcg/paren_2/sl.py b/prolog/problems/dcg/paren_2/sl.py new file mode 100644 index 0000000..0ec52cc --- /dev/null +++ b/prolog/problems/dcg/paren_2/sl.py @@ -0,0 +1,11 @@ +# coding=utf-8 + +name = 'paren/2' +slug = 'Pravilno gnezdeni oklepaji' + +description = '''\ +

Napiši gramatiko z začetnim simbolom paren za jezik pravilno gnezdenih zaporedij oklepajev. Terminale v tej gramatiki piši takole: ['('] in [')'].

+

Primeri veljavnih besed: (), (()), ()(()), (()())().

+

Primeri neveljavnih besed: )(, (((), )).

''' + +hint = {} diff --git a/prolog/problems/dcg/paren_3/sl.py b/prolog/problems/dcg/paren_3/sl.py new file mode 100644 index 0000000..a98eb8b --- /dev/null +++ b/prolog/problems/dcg/paren_3/sl.py @@ -0,0 +1,14 @@ +# coding=utf-8 + +name = 'paren/3' +slug = 'Pravilno gnezdeni oklepaji s pomenom' + +description = '''\ +

Napiši gramatiko z začetnim simbolom paren za jezik pravilno gnezdenih zaporedij oklepajev. Pomen besede v tem jeziku je največja globina gnezdenja oklepajev.

+
+  ?- paren(D, ['(','(',')',')','(',')'], []).  % (())()
+    D = 2.
+
+''' + +hint = {} -- cgit v1.2.1 From 33e86fa3601d2afa295ad277ed066592092247c5 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 15 Dec 2015 12:42:09 +0100 Subject: Hide Prolog.{denotational_semantics,trees} problems --- prolog/problems/denotational_semantics/algol_3/common.py | 2 +- prolog/problems/denotational_semantics/algol_for_3/common.py | 2 +- prolog/problems/denotational_semantics/algol_if_3/common.py | 2 +- prolog/problems/denotational_semantics/prog_8puzzle_2/common.py | 2 +- prolog/problems/denotational_semantics/prog_8puzzle_3/common.py | 2 +- prolog/problems/denotational_semantics/prog_listswap_2/common.py | 2 +- prolog/problems/denotational_semantics/prog_listswap_3/common.py | 2 +- prolog/problems/trees/deletebt_3/common.py | 2 +- prolog/problems/trees/depthbt_2/common.py | 2 +- prolog/problems/trees/insertbt_3/common.py | 2 +- prolog/problems/trees/maxt_2/common.py | 2 +- prolog/problems/trees/memberbt_2/common.py | 2 +- prolog/problems/trees/membert_2/common.py | 2 +- prolog/problems/trees/mirrorbt_2/common.py | 2 +- prolog/problems/trees/numberbt_2/common.py | 2 +- prolog/problems/trees/tolistbt_2/common.py | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/denotational_semantics/algol_3/common.py b/prolog/problems/denotational_semantics/algol_3/common.py index cce9b69..d7607c4 100644 --- a/prolog/problems/denotational_semantics/algol_3/common.py +++ b/prolog/problems/denotational_semantics/algol_3/common.py @@ -2,7 +2,7 @@ id = 176 number = 83 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/denotational_semantics/algol_for_3/common.py b/prolog/problems/denotational_semantics/algol_for_3/common.py index 4cf9373..3261c99 100644 --- a/prolog/problems/denotational_semantics/algol_for_3/common.py +++ b/prolog/problems/denotational_semantics/algol_for_3/common.py @@ -2,7 +2,7 @@ id = 178 number = 85 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/denotational_semantics/algol_if_3/common.py b/prolog/problems/denotational_semantics/algol_if_3/common.py index 0c52886..faf0e4c 100644 --- a/prolog/problems/denotational_semantics/algol_if_3/common.py +++ b/prolog/problems/denotational_semantics/algol_if_3/common.py @@ -2,7 +2,7 @@ id = 177 number = 84 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/denotational_semantics/prog_8puzzle_2/common.py b/prolog/problems/denotational_semantics/prog_8puzzle_2/common.py index d994039..c6d4db0 100644 --- a/prolog/problems/denotational_semantics/prog_8puzzle_2/common.py +++ b/prolog/problems/denotational_semantics/prog_8puzzle_2/common.py @@ -2,7 +2,7 @@ id = 172 number = 81 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/denotational_semantics/prog_8puzzle_3/common.py b/prolog/problems/denotational_semantics/prog_8puzzle_3/common.py index 15dce6b..494f628 100644 --- a/prolog/problems/denotational_semantics/prog_8puzzle_3/common.py +++ b/prolog/problems/denotational_semantics/prog_8puzzle_3/common.py @@ -2,7 +2,7 @@ id = 173 number = 82 -visible = True +visible = False facts = 'denotational_semantics_aux__predicates' solution = '''\ diff --git a/prolog/problems/denotational_semantics/prog_listswap_2/common.py b/prolog/problems/denotational_semantics/prog_listswap_2/common.py index 1f8b655..020b31c 100644 --- a/prolog/problems/denotational_semantics/prog_listswap_2/common.py +++ b/prolog/problems/denotational_semantics/prog_listswap_2/common.py @@ -2,7 +2,7 @@ id = 175 number = 79 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/denotational_semantics/prog_listswap_3/common.py b/prolog/problems/denotational_semantics/prog_listswap_3/common.py index a40be29..6f96f85 100644 --- a/prolog/problems/denotational_semantics/prog_listswap_3/common.py +++ b/prolog/problems/denotational_semantics/prog_listswap_3/common.py @@ -2,7 +2,7 @@ id = 174 number = 80 -visible = True +visible = False facts = 'denotational_semantics_aux__predicates' solution = '''\ diff --git a/prolog/problems/trees/deletebt_3/common.py b/prolog/problems/trees/deletebt_3/common.py index 98ad95f..52f9e3f 100644 --- a/prolog/problems/trees/deletebt_3/common.py +++ b/prolog/problems/trees/deletebt_3/common.py @@ -2,7 +2,7 @@ id = 137 number = 47 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/depthbt_2/common.py b/prolog/problems/trees/depthbt_2/common.py index 85dfa27..4542419 100644 --- a/prolog/problems/trees/depthbt_2/common.py +++ b/prolog/problems/trees/depthbt_2/common.py @@ -2,7 +2,7 @@ id = 140 number = 45 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/insertbt_3/common.py b/prolog/problems/trees/insertbt_3/common.py index f8ef004..eb1ea94 100644 --- a/prolog/problems/trees/insertbt_3/common.py +++ b/prolog/problems/trees/insertbt_3/common.py @@ -2,7 +2,7 @@ id = 138 number = 48 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/maxt_2/common.py b/prolog/problems/trees/maxt_2/common.py index 280cb25..b1cdb39 100644 --- a/prolog/problems/trees/maxt_2/common.py +++ b/prolog/problems/trees/maxt_2/common.py @@ -2,7 +2,7 @@ id = 143 number = 50 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/memberbt_2/common.py b/prolog/problems/trees/memberbt_2/common.py index f5e5435..6df89e3 100644 --- a/prolog/problems/trees/memberbt_2/common.py +++ b/prolog/problems/trees/memberbt_2/common.py @@ -2,7 +2,7 @@ id = 135 number = 42 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/membert_2/common.py b/prolog/problems/trees/membert_2/common.py index c91371e..7d8f207 100644 --- a/prolog/problems/trees/membert_2/common.py +++ b/prolog/problems/trees/membert_2/common.py @@ -2,7 +2,7 @@ id = 142 number = 49 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/mirrorbt_2/common.py b/prolog/problems/trees/mirrorbt_2/common.py index cc271cc..1ee0a9c 100644 --- a/prolog/problems/trees/mirrorbt_2/common.py +++ b/prolog/problems/trees/mirrorbt_2/common.py @@ -2,7 +2,7 @@ id = 136 number = 43 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/numberbt_2/common.py b/prolog/problems/trees/numberbt_2/common.py index 7df71d8..e75075e 100644 --- a/prolog/problems/trees/numberbt_2/common.py +++ b/prolog/problems/trees/numberbt_2/common.py @@ -2,7 +2,7 @@ id = 139 number = 44 -visible = True +visible = False facts = None solution = '''\ diff --git a/prolog/problems/trees/tolistbt_2/common.py b/prolog/problems/trees/tolistbt_2/common.py index e6c8ffd..3c14c4e 100644 --- a/prolog/problems/trees/tolistbt_2/common.py +++ b/prolog/problems/trees/tolistbt_2/common.py @@ -2,7 +2,7 @@ id = 141 number = 46 -visible = True +visible = False facts = None solution = '''\ -- cgit v1.2.1 From 85e4a0147d722b9a12652d559fc96d64ccf01ac4 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 23 Dec 2015 15:43:10 +0100 Subject: Hide problem Prolog.family_relations.connected_3 --- prolog/problems/family_relations/connected_3/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'prolog/problems') diff --git a/prolog/problems/family_relations/connected_3/common.py b/prolog/problems/family_relations/connected_3/common.py index 2555fe9..b6356a9 100644 --- a/prolog/problems/family_relations/connected_3/common.py +++ b/prolog/problems/family_relations/connected_3/common.py @@ -6,7 +6,7 @@ import server.problems id = 102 number = 9 -visible = True +visible = False facts = 'family_relations' solution = '''\ -- 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/clp_fd/common.py | 2 ++ prolog/problems/clp_r/common.py | 2 ++ prolog/problems/dcg/common.py | 2 ++ prolog/problems/denotational_semantics/common.py | 2 ++ prolog/problems/family_relations/common.py | 2 ++ prolog/problems/license_plates/common.py | 2 ++ prolog/problems/lists/common.py | 2 ++ prolog/problems/old_exams/common.py | 2 ++ prolog/problems/other/common.py | 2 ++ prolog/problems/sets/common.py | 2 ++ prolog/problems/sorting/common.py | 2 ++ prolog/problems/trees/common.py | 2 ++ 12 files changed, 24 insertions(+) (limited to 'prolog/problems') diff --git a/prolog/problems/clp_fd/common.py b/prolog/problems/clp_fd/common.py index 3b1f9cf..845ed8b 100644 --- a/prolog/problems/clp_fd/common.py +++ b/prolog/problems/clp_fd/common.py @@ -1,2 +1,4 @@ id = 8 number = 7 + +allowed_groups = ['lists'] diff --git a/prolog/problems/clp_r/common.py b/prolog/problems/clp_r/common.py index 2238250..4136a33 100644 --- a/prolog/problems/clp_r/common.py +++ b/prolog/problems/clp_r/common.py @@ -1,2 +1,4 @@ id = 9 number = 8 + +allowed_groups = ['lists'] diff --git a/prolog/problems/dcg/common.py b/prolog/problems/dcg/common.py index 4992f2d..19fc104 100644 --- a/prolog/problems/dcg/common.py +++ b/prolog/problems/dcg/common.py @@ -1,2 +1,4 @@ id = 10 number = 9 + +allowed_groups = ['dcg', 'lists'] diff --git a/prolog/problems/denotational_semantics/common.py b/prolog/problems/denotational_semantics/common.py index e2c420e..57be52d 100644 --- a/prolog/problems/denotational_semantics/common.py +++ b/prolog/problems/denotational_semantics/common.py @@ -1,2 +1,4 @@ id = 11 number = 10 + +allowed_groups = ['lists'] diff --git a/prolog/problems/family_relations/common.py b/prolog/problems/family_relations/common.py index 5aff819..f292faa 100644 --- a/prolog/problems/family_relations/common.py +++ b/prolog/problems/family_relations/common.py @@ -1,2 +1,4 @@ id = 1 number = 1 + +allowed_groups = ['family_relations'] diff --git a/prolog/problems/license_plates/common.py b/prolog/problems/license_plates/common.py index 3d15487..eab76a6 100644 --- a/prolog/problems/license_plates/common.py +++ b/prolog/problems/license_plates/common.py @@ -1,2 +1,4 @@ id = 7 number = 6 + +allowed_groups = ['license_plates', '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'] diff --git a/prolog/problems/old_exams/common.py b/prolog/problems/old_exams/common.py index 56857ba..949859b 100644 --- a/prolog/problems/old_exams/common.py +++ b/prolog/problems/old_exams/common.py @@ -1 +1,3 @@ id = 12 + +allowed_groups = ['lists'] diff --git a/prolog/problems/other/common.py b/prolog/problems/other/common.py index 50384ad..25978e7 100644 --- a/prolog/problems/other/common.py +++ b/prolog/problems/other/common.py @@ -1 +1,3 @@ id = 4 + +allowed_groups = ['lists'] diff --git a/prolog/problems/sets/common.py b/prolog/problems/sets/common.py index 104aa9d..9318010 100644 --- a/prolog/problems/sets/common.py +++ b/prolog/problems/sets/common.py @@ -1,2 +1,4 @@ id = 5 number = 4 + +allowed_groups = ['sets', 'lists'] diff --git a/prolog/problems/sorting/common.py b/prolog/problems/sorting/common.py index f006f10..1ad1c8c 100644 --- a/prolog/problems/sorting/common.py +++ b/prolog/problems/sorting/common.py @@ -1,2 +1,4 @@ id = 3 number = 3 + +allowed_groups = ['sorting', 'lists'] diff --git a/prolog/problems/trees/common.py b/prolog/problems/trees/common.py index a519878..d9ebca1 100644 --- a/prolog/problems/trees/common.py +++ b/prolog/problems/trees/common.py @@ -1,2 +1,4 @@ id = 6 number = 5 + +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/clp_fd/gcd_3/common.py | 7 ++----- prolog/problems/clp_fd/magic_1/common.py | 7 ++----- prolog/problems/clp_fd/puzzle_abc_3/common.py | 7 ++----- prolog/problems/clp_fd/puzzle_beth_1/common.py | 7 ++----- prolog/problems/clp_fd/puzzle_momson_2/common.py | 7 ++----- prolog/problems/clp_fd/puzzle_ratio_2/common.py | 7 ++----- prolog/problems/clp_fd/tobase_3/common.py | 7 ++----- prolog/problems/family_relations/ancestor_2/common.py | 8 ++------ prolog/problems/family_relations/aunt_2/common.py | 8 ++------ prolog/problems/family_relations/brother_2/common.py | 8 ++------ prolog/problems/family_relations/connected_3/common.py | 8 ++------ prolog/problems/family_relations/cousin_2/common.py | 8 ++------ prolog/problems/family_relations/descendant_2/common.py | 8 ++------ prolog/problems/family_relations/father_2/common.py | 8 ++------ prolog/problems/family_relations/grandparent_2/common.py | 8 ++------ prolog/problems/family_relations/mother_2/common.py | 8 ++------ prolog/problems/family_relations/sister_2/common.py | 8 ++------ prolog/problems/license_plates/checklicenseplate_3/common.py | 7 ++----- prolog/problems/license_plates/firstminus_2/common.py | 7 ++----- prolog/problems/license_plates/genexp_2/common.py | 7 ++----- prolog/problems/license_plates/getdigits_2/common.py | 7 ++----- prolog/problems/license_plates/joindigits_2/common.py | 7 ++----- 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 ++----- prolog/problems/sets/diff_3/common.py | 7 ++----- prolog/problems/sets/intersect_3/common.py | 7 ++----- prolog/problems/sets/is_subset_2/common.py | 7 ++----- prolog/problems/sets/is_superset_2/common.py | 7 ++----- prolog/problems/sets/powerset_2/common.py | 7 ++----- prolog/problems/sets/subset_2/common.py | 7 ++----- prolog/problems/sets/union_3/common.py | 7 ++----- prolog/problems/sorting/is_sorted_1/common.py | 7 ++----- prolog/problems/sorting/isort_2/common.py | 7 ++----- prolog/problems/sorting/pivoting_4/common.py | 7 ++----- prolog/problems/sorting/quick_sort_2/common.py | 7 ++----- prolog/problems/sorting/sins_3/common.py | 7 ++----- prolog/problems/sorting/slowest_sort_ever_2/common.py | 7 ++----- 53 files changed, 106 insertions(+), 275 deletions(-) (limited to 'prolog/problems') diff --git a/prolog/problems/clp_fd/gcd_3/common.py b/prolog/problems/clp_fd/gcd_3/common.py index 6e62e3b..f24e0bb 100644 --- a/prolog/problems/clp_fd/gcd_3/common.py +++ b/prolog/problems/clp_fd/gcd_3/common.py @@ -35,14 +35,11 @@ test_cases = [ [{'X': '6'}]), ] -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/clp_fd/magic_1/common.py b/prolog/problems/clp_fd/magic_1/common.py index b897cb3..3ffe72f 100644 --- a/prolog/problems/clp_fd/magic_1/common.py +++ b/prolog/problems/clp_fd/magic_1/common.py @@ -33,14 +33,11 @@ test_cases = [ [8, 1, 6, 3, 5, 7, 4, 9, 2], [8, 3, 4, 1, 5, 9, 6, 7, 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/clp_fd/puzzle_abc_3/common.py b/prolog/problems/clp_fd/puzzle_abc_3/common.py index 34ad409..ffce416 100644 --- a/prolog/problems/clp_fd/puzzle_abc_3/common.py +++ b/prolog/problems/clp_fd/puzzle_abc_3/common.py @@ -25,14 +25,11 @@ test_cases = [ [{'X': '[12/10/5]'}]), ] -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/clp_fd/puzzle_beth_1/common.py b/prolog/problems/clp_fd/puzzle_beth_1/common.py index 8a975ee..fb00516 100644 --- a/prolog/problems/clp_fd/puzzle_beth_1/common.py +++ b/prolog/problems/clp_fd/puzzle_beth_1/common.py @@ -20,14 +20,11 @@ test_cases = [ [{'X': '[12]'}]), ] -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/clp_fd/puzzle_momson_2/common.py b/prolog/problems/clp_fd/puzzle_momson_2/common.py index 0f9e0a8..906bd15 100644 --- a/prolog/problems/clp_fd/puzzle_momson_2/common.py +++ b/prolog/problems/clp_fd/puzzle_momson_2/common.py @@ -27,14 +27,11 @@ test_cases = [ [{'X': '[42/24, 51/15]'}]), ] -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/clp_fd/puzzle_ratio_2/common.py b/prolog/problems/clp_fd/puzzle_ratio_2/common.py index eca7f62..736cd2e 100644 --- a/prolog/problems/clp_fd/puzzle_ratio_2/common.py +++ b/prolog/problems/clp_fd/puzzle_ratio_2/common.py @@ -28,14 +28,11 @@ test_cases = [ [{'X': '[30/24]'}]), ] -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/clp_fd/tobase_3/common.py b/prolog/problems/clp_fd/tobase_3/common.py index 5e3a783..3783396 100644 --- a/prolog/problems/clp_fd/tobase_3/common.py +++ b/prolog/problems/clp_fd/tobase_3/common.py @@ -36,14 +36,11 @@ test_cases = [ [{'X': '[2/1111011, 3/11120, 4/1323, 5/443, 6/323, 7/234, 8/173, 9/146, 10/123]'}]), ] -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/family_relations/ancestor_2/common.py b/prolog/problems/family_relations/ancestor_2/common.py index 68cbc6d..48ea512 100644 --- a/prolog/problems/family_relations/ancestor_2/common.py +++ b/prolog/problems/family_relations/ancestor_2/common.py @@ -40,15 +40,11 @@ test_cases = [ [{'X': 'vanessa'}, {'X': 'patrick'}, {'X': 'tina'}, {'X': 'thomas'}, {'X': 'william'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/aunt_2/common.py b/prolog/problems/family_relations/aunt_2/common.py index b0a18bf..507460f 100644 --- a/prolog/problems/family_relations/aunt_2/common.py +++ b/prolog/problems/family_relations/aunt_2/common.py @@ -44,15 +44,11 @@ test_cases = [ [{'X': 'vanessa'}, {'X': 'patricia'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py index 4d01c0b..556d0e9 100644 --- a/prolog/problems/family_relations/brother_2/common.py +++ b/prolog/problems/family_relations/brother_2/common.py @@ -38,15 +38,11 @@ test_cases = [ [{'X': 'jeffrey'}, {'X': 'william'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/connected_3/common.py b/prolog/problems/family_relations/connected_3/common.py index b6356a9..31d0d12 100644 --- a/prolog/problems/family_relations/connected_3/common.py +++ b/prolog/problems/family_relations/connected_3/common.py @@ -29,15 +29,11 @@ test_cases = [ # [{'X': 'vanessa'}, {'X': 'patricia'}, {'X': 'susan'}, {'X': 'john'}, {'X': 'michael'}, {'X': 'michelle'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/cousin_2/common.py b/prolog/problems/family_relations/cousin_2/common.py index 382c7a0..0f7a37d 100644 --- a/prolog/problems/family_relations/cousin_2/common.py +++ b/prolog/problems/family_relations/cousin_2/common.py @@ -51,15 +51,11 @@ test_cases = [ [{'X': 'andrew'}, {'X': 'melanie'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/descendant_2/common.py b/prolog/problems/family_relations/descendant_2/common.py index e979b0f..f419b1d 100644 --- a/prolog/problems/family_relations/descendant_2/common.py +++ b/prolog/problems/family_relations/descendant_2/common.py @@ -40,15 +40,11 @@ test_cases = [ [{'X': 'vanessa'}, {'X': 'patricia'}, {'X': 'susan'}, {'X': 'john'}, {'X': 'michael'}, {'X': 'michelle'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py index 45b9255..f5888de 100644 --- a/prolog/problems/family_relations/father_2/common.py +++ b/prolog/problems/family_relations/father_2/common.py @@ -41,15 +41,11 @@ test_cases = [ [{'X': 'aleksandr'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py index 0c902da..663c9e4 100644 --- a/prolog/problems/family_relations/grandparent_2/common.py +++ b/prolog/problems/family_relations/grandparent_2/common.py @@ -42,15 +42,11 @@ test_cases = [ [{'X': 'vanessa'}, {'X': 'patricia'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/mother_2/common.py b/prolog/problems/family_relations/mother_2/common.py index 535e7ed..0a4c7bf 100644 --- a/prolog/problems/family_relations/mother_2/common.py +++ b/prolog/problems/family_relations/mother_2/common.py @@ -42,15 +42,11 @@ test_cases = [ [{'X': 'steve'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/family_relations/sister_2/common.py b/prolog/problems/family_relations/sister_2/common.py index 1eb4a6a..90039e3 100644 --- a/prolog/problems/family_relations/sister_2/common.py +++ b/prolog/problems/family_relations/sister_2/common.py @@ -39,15 +39,11 @@ test_cases = [ [{'X': 'melanie'}]), ] -def test(program, solved_problems): - code = (program + '\n' + - server.problems.solutions_for_problems('prolog', solved_problems) + '\n' + - server.problems.load_facts('prolog', facts).facts) - +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/license_plates/checklicenseplate_3/common.py b/prolog/problems/license_plates/checklicenseplate_3/common.py index 0480258..6741e69 100644 --- a/prolog/problems/license_plates/checklicenseplate_3/common.py +++ b/prolog/problems/license_plates/checklicenseplate_3/common.py @@ -71,14 +71,11 @@ test_cases = [ {'E1': '-8/2', 'E2': '-1-3'}, {'E1': '8/2', 'E2': '1+3'}]), ] -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/license_plates/firstminus_2/common.py b/prolog/problems/license_plates/firstminus_2/common.py index 89fe3b0..8831fe2 100644 --- a/prolog/problems/license_plates/firstminus_2/common.py +++ b/prolog/problems/license_plates/firstminus_2/common.py @@ -22,14 +22,11 @@ test_cases = [ [{'X': '[5, 2, 3, 4]'}, {'X': '[-5, 2, 3, 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: diff --git a/prolog/problems/license_plates/genexp_2/common.py b/prolog/problems/license_plates/genexp_2/common.py index 4b097f2..6c3dd17 100644 --- a/prolog/problems/license_plates/genexp_2/common.py +++ b/prolog/problems/license_plates/genexp_2/common.py @@ -43,14 +43,11 @@ test_cases = [ {'X': '1+2/3'}, {'X': '1-2/3'}, {'X': '1*(2/3)'}, {'X': '1/(2/3)'}]), ] -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/license_plates/getdigits_2/common.py b/prolog/problems/license_plates/getdigits_2/common.py index 4ae42ff..6650b5a 100644 --- a/prolog/problems/license_plates/getdigits_2/common.py +++ b/prolog/problems/license_plates/getdigits_2/common.py @@ -27,14 +27,11 @@ test_cases = [ [{'X': '[3, 2, 4, 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/license_plates/joindigits_2/common.py b/prolog/problems/license_plates/joindigits_2/common.py index 189f221..1c5dba8 100644 --- a/prolog/problems/license_plates/joindigits_2/common.py +++ b/prolog/problems/license_plates/joindigits_2/common.py @@ -26,14 +26,11 @@ test_cases = [ [{'X': '[2, 3, 1]'}, {'X': '[2, 31]'}, {'X': '[23, 1]'}, {'X': '[231]'}]), ] -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/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: diff --git a/prolog/problems/sets/diff_3/common.py b/prolog/problems/sets/diff_3/common.py index e2706cb..bfa3ce6 100644 --- a/prolog/problems/sets/diff_3/common.py +++ b/prolog/problems/sets/diff_3/common.py @@ -38,14 +38,11 @@ test_cases = [ [{'X': '[]'}]), ] -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/sets/intersect_3/common.py b/prolog/problems/sets/intersect_3/common.py index ba90db7..55d2df5 100644 --- a/prolog/problems/sets/intersect_3/common.py +++ b/prolog/problems/sets/intersect_3/common.py @@ -37,14 +37,11 @@ test_cases = [ [{'X': '[1, 2, 4, 7, 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: diff --git a/prolog/problems/sets/is_subset_2/common.py b/prolog/problems/sets/is_subset_2/common.py index a64d0f8..0d78cd6 100644 --- a/prolog/problems/sets/is_subset_2/common.py +++ b/prolog/problems/sets/is_subset_2/common.py @@ -31,14 +31,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/sets/is_superset_2/common.py b/prolog/problems/sets/is_superset_2/common.py index abd3cfb..59f2fda 100644 --- a/prolog/problems/sets/is_superset_2/common.py +++ b/prolog/problems/sets/is_superset_2/common.py @@ -31,14 +31,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/sets/powerset_2/common.py b/prolog/problems/sets/powerset_2/common.py index 77801d7..e97603c 100644 --- a/prolog/problems/sets/powerset_2/common.py +++ b/prolog/problems/sets/powerset_2/common.py @@ -29,14 +29,11 @@ test_cases = [ [{'X': '[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]'}]), ] -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/sets/subset_2/common.py b/prolog/problems/sets/subset_2/common.py index 99d0799..f7d87d2 100644 --- a/prolog/problems/sets/subset_2/common.py +++ b/prolog/problems/sets/subset_2/common.py @@ -42,14 +42,11 @@ test_cases = [ {'X': '[2, 5, 6, 7]'}, {'X': '[0, 5, 6, 7]'}, {'X': '[0, 2, 5, 6, 7]'}]), ] -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/sets/union_3/common.py b/prolog/problems/sets/union_3/common.py index 774c8cf..ae24943 100644 --- a/prolog/problems/sets/union_3/common.py +++ b/prolog/problems/sets/union_3/common.py @@ -34,14 +34,11 @@ 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: diff --git a/prolog/problems/sorting/is_sorted_1/common.py b/prolog/problems/sorting/is_sorted_1/common.py index 9213ddc..db5c3cc 100644 --- a/prolog/problems/sorting/is_sorted_1/common.py +++ b/prolog/problems/sorting/is_sorted_1/common.py @@ -34,14 +34,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/sorting/isort_2/common.py b/prolog/problems/sorting/isort_2/common.py index 6041b35..1669a4a 100644 --- a/prolog/problems/sorting/isort_2/common.py +++ b/prolog/problems/sorting/isort_2/common.py @@ -33,14 +33,11 @@ test_cases = [ [{'X': '[1, 2, 3, 4, 5]'}]), ] -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/sorting/pivoting_4/common.py b/prolog/problems/sorting/pivoting_4/common.py index 0e9afaa..3a3a906 100644 --- a/prolog/problems/sorting/pivoting_4/common.py +++ b/prolog/problems/sorting/pivoting_4/common.py @@ -30,14 +30,11 @@ test_cases = [ [{'A': '[1, 0, 3, -2]', 'B': '[22, 8, 5, 7]'}]), ] -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/sorting/quick_sort_2/common.py b/prolog/problems/sorting/quick_sort_2/common.py index b1449f1..d46c185 100644 --- a/prolog/problems/sorting/quick_sort_2/common.py +++ b/prolog/problems/sorting/quick_sort_2/common.py @@ -39,14 +39,11 @@ test_cases = [ [{'X': '[1, 2, 3, 4, 5]'}]), ] -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/sorting/sins_3/common.py b/prolog/problems/sorting/sins_3/common.py index 4c707ca..efc544e 100644 --- a/prolog/problems/sorting/sins_3/common.py +++ b/prolog/problems/sorting/sins_3/common.py @@ -31,14 +31,11 @@ test_cases = [ [{'X': '[2, 2, 3, 4, 5, 6, 7]'}]), ] -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/sorting/slowest_sort_ever_2/common.py b/prolog/problems/sorting/slowest_sort_ever_2/common.py index 72e25e2..5d0f566 100644 --- a/prolog/problems/sorting/slowest_sort_ever_2/common.py +++ b/prolog/problems/sorting/slowest_sort_ever_2/common.py @@ -40,14 +40,11 @@ test_cases = [ [{'X': '[2, 3, 4, 5]'}]), ] -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