-
Notifications
You must be signed in to change notification settings - Fork 0
How to Use
This program utilizes String inputs to get the solutions. It is necessary to pay attention to the outputs of each operation so the String can work. The Operation Strings where design so you can make more diverse operations.
When combined, you can understand the operations that return sets as a unique set.
The operations that returns sets are:
OPERATION | OPERATOR |
---|---|
Union | + |
Subtraction | - |
Intersection | * |
Given Sets A = {1, 3, 5}
, B = {1, 2, 4}
and C = {5, 2, 9}
, then
-----------------------------------------------
OPERATION STRING: A + B - C
-----------------------------------------------
SOLUTION: {1, 4, 3}
-----------------------------------------------
You can compare if an Element belongs to a Set or a Combination of Sets.
The element operators are:
OPERATION | OPERATOR |
---|---|
Belongs | < |
Does not belong | > |
The only thing you should pay attention is that this comparison must follow the structure:
element (element operator) set
The element and element operator needs to be in the beginning of the string. The semantics matters.
Given Sets A = {1, 3, 5}
, B = {1, 2, 4}
and C = {5, 2, 9}
, and Element x = 2
, then:
-----------------------------------------------
OPERATION STRING: x < A * B - C
-----------------------------------------------
SOLUTION: false
-----------------------------------------------
Operations between sets can be written as:
set (operation) set
Set can be a Combination of Sets
The operations between sets two sets are:
OPERATION | OPERATOR |
---|---|
Subset | ( |
Not Subset | ) |
Proper subset | [ |
Not proper subset | ] |
Cartesian Product | x |
Given Sets A = {1, 3, 5}
, B = {1, 2, 4}
and C = {5, 2, 9}
, then:
-----------------------------------------------
OPERATION STRING: A + B ] C * A
-----------------------------------------------
SOLUTION: true
-----------------------------------------------
Inside the powerset brackets, a Set or Combination of Sets can be included.
Given Sets A = {1, 3, 5}
, B = {1, 2, 4}
and C = {5, 2, 9}
, then:
-----------------------------------------------
OPERATION STRING: P(A - B * C)
-----------------------------------------------
SOLUTION: {{ }, {2}}
-----------------------------------------------
When the program starts, it show the Sets and Elements founded in the file set.txt
.
With these, you can choose one of the following operations, that are represented by a special characther:
OPERATION | OPERATOR |
---|---|
Union | + |
Subtraction | - |
Intersection | * |
Belongs | < |
Does not belong | > |
Subset | ( |
Not Subset | ) |
Proper subset | [ |
Not proper subset | ] |
Cartesian Product | x |
Powerset | P() |
It's important to pay attention to the syntax of each operation.
The union (+
) of two sets A and B is the set of elements which are in A, in B, or in both A and B.
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: A + B
-----------------------------------------------
SOLUTION: {1, 2, 3, 4, 5, 6, 7}
-----------------------------------------------
The subtraction (-
) of B and A, is the set of elements in B but not in A.
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: B - A
-----------------------------------------------
SOLUTION: {2, 4, 5, 6}
-----------------------------------------------
The intersection (*
) is the set containing all elements of A that also belong to B (or equivalently, all elements of B that also belong to A)
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: B * A
-----------------------------------------------
SOLUTION: {1, 7}
-----------------------------------------------
The belongs (<
) test returns if an element x belongs to a set A.
Given Set A = {1, 3, 5, 7}
and Element x = 3
, then
-----------------------------------------------
OPERATION STRING: x < A
-----------------------------------------------
SOLUTION: true
-----------------------------------------------
The Does not belong (>
) test returns if an element x belongs to a set A.
Given Set A = {1, 3, 5, 7}
and Element x = 3
, then
-----------------------------------------------
OPERATION STRING: x > A
-----------------------------------------------
SOLUTION: false
-----------------------------------------------
The Subset ((
) test returns if every element of A belongs to B. A can be equal to B.
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: A ( B
-----------------------------------------------
SOLUTION: false
-----------------------------------------------
The Not subset ()
) test returns if not every element of A belongs to B.
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: A ) B
-----------------------------------------------
SOLUTION: true
-----------------------------------------------
The Proper subset ([
) test returns if every element of A belongs to B. A can't be equal to B.
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: A [ B
-----------------------------------------------
SOLUTION: false
-----------------------------------------------
The Not Proper subset (]
) test returns if not every element of A belongs to B.
Given Sets A = {1, 3, 5, 7}
and B = {1, 2, 4, 6, 7}
, then
-----------------------------------------------
OPERATION STRING: A ] B
-----------------------------------------------
SOLUTION: true
-----------------------------------------------
The Cartesian Product (x
) of two sets A and B, is the set of all ordered pairs <a, b> where a is in A and b is in B.
Given Sets A = {1, 3, 5}
and B = {5, 6}
, then
-----------------------------------------------
OPERATION STRING: A x B
-----------------------------------------------
SOLUTION: {<1,5>, <1,6>, <3,5>, <3,6>, <5,5>, <5,6>}
-----------------------------------------------
It is a reversive operation, which means that you can redefine the sets that originated this result.
The Powerset (P()
) is the set of all subsets of A, including the empty set and A itself.
Given Set A = {1, 3, 5}
, then
-----------------------------------------------
OPERATION STRING: P(A)
-----------------------------------------------
SOLUTION: {{ }, {1}, {3}, {3, 1}, {5}, {5, 1}, {5, 3}, {5, 3, 1}}
-----------------------------------------------
It is a reversive operation, which means that you can redefine the sets that originated this result.
Home > Technologies > Setup > How to Use