Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-204

Fault Tree AND-OR

Problem

Given cut sets where each cut set is a list of independent event probabilities, the top event occurs if some cut set has all of its events (AND within a cut set, OR across cut sets):

P = 1 - product over cut sets of (1 - product of probabilities in the cut set).

Return 0.0 when there are no cut sets.

Hint

An AND gate multiplies probabilities; an OR gate complements a product.

Test cases

case 1
in: [[[0.1,0.2],[0.3]]]
expected: 0.31400000000000006
case 2
in: [[[0.5,0.5]]]
expected: 0.25
case 3
in: [[[1],[0.5]]]
expected: 1
case 4
in: [[]]
expected: 0
case 5
in: [[[]]]
expected: 1
Starter codePython
def fault_tree_and_or(cut_sets):
    # Your code here
    pass

5 test cases · run your code against them in the editor