9. De Morgan's Laws

Medium

De Morgan's laws let you turn a complement of a union into an intersection of complements, and vice versa:

(AB)c=AcBc(AB)c=AcBc(A \cup B)^c = A^c \cap B^c \qquad (A \cap B)^c = A^c \cup B^c

Return a dict with both complements:

keyvalue
"not_a_or_b"(AB)c(A \cup B)^c
"not_a_and_b"(AB)c(A \cap B)^c

Compute each one using the right-hand side of the matching law (complement each event first, then combine) and confirm for yourself that it agrees with the direct route.

solve({2,4,6}, {4,5,6}, {1,2,3,4,5,6})
->  {"not_a_or_b": {1, 3}, "not_a_and_b": {1, 2, 3, 5}}

Sign in to write and run your own code.

Implement solve(...)