Let be a set of integers. For example:
The powerset of is the set of all subsets of :
Note in particular that:
A set of sets of integers can be represented as a text file. Each line represents a set of integers. The empty set can be represented as an empty line. For example, the set
can be represented as follows:
1 2 4 1 -2 -17 5 6
The same set can also be represented as a file which looks like this:
(define A '( (1 2) () (4) (1 -2 -17) (5 6) ))
Use whichever format you prefer.
Write a program which decides whether or not a set of sets of integers is a powerset. The program prints ``good'' if the file represents a powerset and ``bad'' otherwise.
Here is an example of ``good'' input:
1 1 -2 -2 17 -2 17 17 -2 1 1 17
(define B '( (1) (1 -2) (-2) (17 -2) (17) (17 -2 1) () (1 17) ))
Here is an example of ``bad'' input:
1 1 -2 -2 17 -2 1 17 5 17 1 17
(define C '( (1) (1 -2) (-2) (17 -2 1) (17 5) (17) () (1 17) ))
Hint: Implement a set ADT. A set is like a list but the order of elements does not matter and there can be no duplicates. Make sure that your ADT is general enough to handle sets of sets.
Who's cuisine reigns supreme? Will it be the Pundits of Perl...or the Champions of Scheme?