BasicsAxiomsGoogleMetaJane Street
Problem
Given a list of probabilities probs for mutually exclusive (disjoint) events, implement disjoint_union_prob(probs) returning the probability that any one of them occurs (∑pi).
Why It Matters: Mutually exclusive outcomes (e.g., rolling a 1, 2, or 3; or a user landing in exactly one bucket) have zero pairwise overlap, so probabilities add directly.
Function Signature
def disjoint_union_prob(probs: list[float]) -> float:
Sample Input & Output
Example 1: Three Disjoint Outcomes
Input:
probs = [0.1, 0.25, 0.3]
Expected Output:
0.65
Explanation: 0.1 + 0.25 + 0.3 = 0.65.
Example 2: Empty Event List
Input:
probs = []
Expected Output:
0.0
Explanation: With no events, the union probability is 0.0.
Constraints & Edge Cases
- Return
float(sum(probs)). - Empty list
[]returns0.0. - Sum of probabilities is guaranteed
<= 1.0.
Constraints & Evaluation Criteria
- Return `float(sum(probs))`.
Hints
Python 3⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
[1/6, 1/6]
Expected Output / Criteria
0.3333