harbor run -t openthoughts/tasktrove-exp-rpt-taco-v2-taco-4720harbor download openthoughts/tasktrove-exp-rpt-taco-v2-taco-4720You are tasked with evaluating expressions that involve sets of integers and various set operations. The operations include union, intersection, difference, symmetric difference, and complement. You will be provided with a universal set that encompasses all the specified sets, and you need to compute the result of given expressions based on the operations defined.
Union (U):
( A \cup B = { x \in U : x \in A \text{ or } x \in B } )
Represents all elements that belong to either set A or set B.
Intersection (I):
( A \cap B = { x \in U : x \in A \text{ and } x \in B } )
Represents elements that are common to both A and B.
Difference (D):
( A \setminus B = { x \in U : x \in A, x \notin B } )
Represents elements in A that are not in B.
Symmetric Difference (S):
( A \Delta B = (A \setminus B) \cup (B \setminus A) )
Represents elements that are in either A or B but not in both.
Complement (C):
( \overline{A} = { x \in U : x \notin A } )
Represents elements in the universal set that are not in A.
The universal set ( U ) is defined as the union of all specified sets.
You need to evaluate given expressions that include set names, operators, and parentheses. The expressions can include multiple operations and nested parentheses.
The input consists of multiple datasets, each comprising:
Several pairs of lines defining sets:
A pair of lines defining an expression:
R 0The number of defined sets can vary from 1 to 5, and set names can be in any order. Each set will contain between 1 and 100 elements. The input terminates when the pair for expression definition is encountered. The input can contain up to 20 datasets.
For each dataset, the output should consist of one line with the resulting set elements sorted in ascending order, separated by spaces. If the result is an empty set, the output should be the word NULL.
A 3
1 3 -1
B 4
3 1 5 7
D 1
5
R 0
cAiBdD
C 3
1 2 3
A 4
2 10 8 3
B 3
2 4 8
R 0
(As(AiB))uC
7
1 2 3 10
Please place your solution in the /app/ directory. Ensure that your code is clean, well-documented, and follows the defined input/output specifications.
Important: place your implementation at /app/solution.py so the verifier can run it.