diff options
Diffstat (limited to 'prolog/problems/sets/subset_2')
-rw-r--r-- | prolog/problems/sets/subset_2/common.py | 13 | ||||
-rw-r--r-- | prolog/problems/sets/subset_2/en.py | 19 |
2 files changed, 32 insertions, 0 deletions
diff --git a/prolog/problems/sets/subset_2/common.py b/prolog/problems/sets/subset_2/common.py new file mode 100644 index 0000000..7fbbf49 --- /dev/null +++ b/prolog/problems/sets/subset_2/common.py @@ -0,0 +1,13 @@ +id = 133 +group = 'sets' +number = 40 +visible = True +facts = None + +solution = '''\ +subset([], []). +subset([H|T], [H|T1]) :- + subset(T, T1). +subset([_|T], T1) :- + subset(T, T1). +''' diff --git a/prolog/problems/sets/subset_2/en.py b/prolog/problems/sets/subset_2/en.py new file mode 100644 index 0000000..9d9132b --- /dev/null +++ b/prolog/problems/sets/subset_2/en.py @@ -0,0 +1,19 @@ +id = 133 +name = 'subset/2' +slug = 'generate all subsets of a set' + +description = '''\ +<p><code>subset(Set, Subset)</code>: the set <code>Subset</code> is a subset of <code>Set</code>. This predicate should generate all valid solutions, one by one.</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 = {} |