All problems
Minimum Distance
Problem
Return the minimum Hamming distance between any two distinct codewords in the list. All codewords have the same length. Return 0 when fewer than two codewords are supplied.
Hint
The minimum distance also equals the minimum weight of a nonzero codeword for linear codes.
Test cases
case 1
in: [[[0,0,0],[1,1,0],[1,0,1]]]
expected: 2
case 2
in: [[[0,0,0],[0,0,1],[0,0,0]]]
expected: 0
case 3
in: [[[1,1,1,1],[0,0,0,0]]]
expected: 4
case 4
in: [[[1,0,1,0,1]]]
expected: 0
case 5
in: [[[0,0],[1,1],[1,0],[0,1]]]
expected: 1
Starter codePython
def minimum_distance(codewords):
# Your code here
pass5 test cases · run your code against them in the editor