All problems
Key Agreement Rate
Problem
Return the achievable secret-key rate from mutual informations:
rate = max(0, I(A;B) - I(A;E))
The legitimate pair must share more information with each other than the eavesdropper shares with them.
Hint
The advantage over the eavesdropper sets the key rate.
Test cases
case 1
in: [2,0.5]
expected: 1.5
case 2
in: [1,1]
expected: 0
case 3
in: [0.5,1]
expected: 0
case 4
in: [3,2]
expected: 1
Starter codePython
def key_agreement_rate(mi_ab, mi_ae):
# Your code here
pass4 test cases · run your code against them in the editor