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/clp_fd') 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/clp_fd') 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/clp_fd') 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 +++++++++++++++++ 7 files changed, 86 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 (limited to 'prolog/problems/clp_fd') 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 = {} -- 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 ++ 1 file changed, 2 insertions(+) (limited to 'prolog/problems/clp_fd') 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'] -- 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 ++----- 7 files changed, 14 insertions(+), 35 deletions(-) (limited to 'prolog/problems/clp_fd') 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: -- cgit v1.2.1