diff options
Diffstat (limited to 'prolog/problems/sets')
-rw-r--r-- | prolog/problems/sets/diff_3/sl.py | 13 | ||||
-rw-r--r-- | prolog/problems/sets/intersect_3/sl.py | 13 | ||||
-rw-r--r-- | prolog/problems/sets/is_subset_2/sl.py | 15 | ||||
-rw-r--r-- | prolog/problems/sets/is_superset_2/sl.py | 15 | ||||
-rw-r--r-- | prolog/problems/sets/powerset_2/sl.py | 13 | ||||
-rw-r--r-- | prolog/problems/sets/subset_2/sl.py | 20 | ||||
-rw-r--r-- | prolog/problems/sets/union_3/sl.py | 13 |
7 files changed, 102 insertions, 0 deletions
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 = '''\ +<p><code>diff(S1, S2, D)</code>: seznam <code>D</code> vsebuje elemente iz <code>S1</code>, ki niso v <code>S2</code>.</p> +<pre> + ?- diff([2,3,5,1,7,9], [3,7,4,5,6], D). + D = [2,1,9]. +</pre>''' + +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 = '''\ +<p><code>intersect(S1, S2, I)</code>: seznam <code>I</code> vsebuje presek elementov v <code>S1</code> in <code>S2</code>.</p> +<pre> + ?- intersect([1,5,6,3,4,2], [8,1,5,9,4,3], I). + I = [1,5,3,4]. +</pre>''' + +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 = '''\ +<p><code>is_subset(S1, S2)</code>: množica <code>S1</code> je podmnožica od <code>S2</code>.</p> +<pre> + ?- 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. +</pre>''' + +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 = '''\ +<p><code>is_superset(S1, S2)</code>: množica <code>S1</code> je nadmnožica (vsebuje vse elemente) od <code>S2</code>.</p> +<pre> + ?- 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. +</pre>''' + +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 = '''\ +<p><code>powerset(Set, Powerset)</code>: množica <code>Powerset</code> vsebuje vse podmnožice od množice <code>Set</code>.</p> +<pre> + ?- powerset([1,2,3], L). + L = [[1,2,3],[1,2],[1,3],[1],[2,3],[2],[3],[]]. +</pre>''' + +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 = '''\ +<p><code>subset(Set, Subset)</code>: množica <code>Subset</code> je podmnožica od <code>Set</code>. Ta predikat naj, eno po eno, generira vse veljavne podmnožice.</p> +<pre> + ?- 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 = []. +</pre>''' + +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 = '''\ +<p><code>union(S1, S2, U)</code>: seznam <code>U</code> predstavlja unijo elementov v seznamih <code>S1</code> in <code>S2</code>, duplikatov (kot se za množice spodobi) ni.</p> +<pre> + ?- union([1,5,2,3], [3,4,8,2], U). + U = [1,5,3,4,8,2]. +</pre>''' + +hint = {} |