23. Are Two Events Independent?

Medium

Events are independent when knowing one tells you nothing about the other:

P(AB)=P(A)P(B)P(A \cap B) = P(A)\,P(B)

Return True if the two events are independent in this sample space, else False. Compare with a tolerance rather than ==.

solve({2,4,6}, {3,6}, {1,2,3,4,5,6})   ->  True     # 1/6 == 1/2 x 1/3
solve({2,4,6}, {4,5,6}, {1,2,3,4,5,6}) ->  False    # 1/3 != 1/4

Sign in to write and run your own code.

Implement solve(...)