diff options
Diffstat (limited to 'prolog/problems')
-rw-r--r-- | prolog/problems/clp_r/max_adj_pair_2/common.py (renamed from prolog/problems/clp_r/max_sum_2/common.py) | 14 | ||||
-rw-r--r-- | prolog/problems/clp_r/max_adj_pair_2/en.py | 15 | ||||
-rw-r--r-- | prolog/problems/clp_r/max_adj_pair_2/sl.py | 15 | ||||
-rw-r--r-- | prolog/problems/clp_r/max_sum_2/en.py | 15 | ||||
-rw-r--r-- | prolog/problems/clp_r/max_sum_2/sl.py | 15 |
5 files changed, 37 insertions, 37 deletions
diff --git a/prolog/problems/clp_r/max_sum_2/common.py b/prolog/problems/clp_r/max_adj_pair_2/common.py index a5e236f..bb2cd18 100644 --- a/prolog/problems/clp_r/max_sum_2/common.py +++ b/prolog/problems/clp_r/max_adj_pair_2/common.py @@ -13,20 +13,20 @@ visible = True facts = None solution = '''\ -max_sum([_], S) :- +max_adj_pair([_], S) :- minimize(S). -max_sum([A,B|T], S) :- +max_adj_pair([A,B|T], S) :- { S >= A + B }, - max_sum([B|T], S).''' + max_adj_pair([B|T], S).''' test_cases = [ - ('max_sum([4.2, 5.1], X), abs(X - 9.3) =< 1e-8', + ('max_adj_pair([4.2, 5.1], X), abs(X - 9.3) =< 1e-8', [{}]), - ('max_sum([4.5, -1.9, 1.3, -2.5, 3.5], X), abs(X - 2.6) =< 1e-8', + ('max_adj_pair([4.5, -1.9, 1.3, -2.5, 3.5], X), abs(X - 2.6) =< 1e-8', [{}]), - ('max_sum([7.5, 8.8, 4.2, 6.5, 2.2], X), abs(X - 16.3) =< 1e-8', + ('max_adj_pair([7.5, 8.8, 4.2, 6.5, 2.2], X), abs(X - 16.3) =< 1e-8', [{}]), - ('max_sum([-2.8, -2.2, 5.5, -2.2, 8.5, 0.7], X), abs(X - 9.2) =< 1e-8', + ('max_adj_pair([-2.8, -2.2, 5.5, -2.2, 8.5, 0.7], X), abs(X - 9.2) =< 1e-8', [{}]), ] diff --git a/prolog/problems/clp_r/max_adj_pair_2/en.py b/prolog/problems/clp_r/max_adj_pair_2/en.py new file mode 100644 index 0000000..d85bbcd --- /dev/null +++ b/prolog/problems/clp_r/max_adj_pair_2/en.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'max_adj_pair/2' +slug = 'find the maximal pair of adjacent elements' + +description = '''\ +<p><code>max_adj_pair(List, Max)</code>: <code>Max</code> is the maximal sum of two adjacent elements in <code>List</code>.</p> +<pre> +?- max_adj_pair([4.5, 3.6, 1.2, 6.7], Max). + Max = 8.1. +?- max_adj_pair([1.1, 1.2, -12.3, 8.8], Max). + Max = 2.3. +</pre>''' + +hint = {} diff --git a/prolog/problems/clp_r/max_adj_pair_2/sl.py b/prolog/problems/clp_r/max_adj_pair_2/sl.py new file mode 100644 index 0000000..eaed41e --- /dev/null +++ b/prolog/problems/clp_r/max_adj_pair_2/sl.py @@ -0,0 +1,15 @@ +# coding=utf-8 + +name = 'max_adj_pair/2' +slug = 'najdi največja sosedna elementa seznama' + +description = '''\ +<p><code>max_adj_pair(List, Max)</code>: <code>Max</code> je največja možna vsota dveh sosednih elementov v seznamu <code>List</code>.</p> +<pre> +?- max_adj_pair([4.5, 3.6, 1.2, 6.7], Max). + Max = 8.1. +?- max_adj_pair([1.1, 1.2, -12.3, 8.8], Max). + Max = 2.3. +</pre>''' + +hint = {} diff --git a/prolog/problems/clp_r/max_sum_2/en.py b/prolog/problems/clp_r/max_sum_2/en.py deleted file mode 100644 index 269f8b3..0000000 --- a/prolog/problems/clp_r/max_sum_2/en.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -name = 'max_sum/2' -slug = 'find maximal adjacent elements' - -description = '''\ -<p><code>max_sum(List, Max)</code>: <code>Max</code> is the maximal sum of two adjacent elements in <code>List</code>.</p> -<pre> -?- max_sum([4.5, 3.6, 1.2, 6.7], Max). - Max = 8.1. -?- max_sum([1.1, 1.2, -12.3, 8.8], Max). - Max = 2.3. -</pre>''' - -hint = {} diff --git a/prolog/problems/clp_r/max_sum_2/sl.py b/prolog/problems/clp_r/max_sum_2/sl.py deleted file mode 100644 index b73459e..0000000 --- a/prolog/problems/clp_r/max_sum_2/sl.py +++ /dev/null @@ -1,15 +0,0 @@ -# coding=utf-8 - -name = 'max_sum/2' -slug = 'najdi največja sosedna elementa seznama' - -description = '''\ -<p><code>max_sum(List, Max)</code>: <code>Max</code> je največja možna vsota dveh sosednih elementov v seznamu <code>List</code>.</p> -<pre> -?- max_sum([4.5, 3.6, 1.2, 6.7], Max). - Max = 8.1. -?- max_sum([1.1, 1.2, -12.3, 8.8], Max). - Max = 2.3. -</pre>''' - -hint = {} |