V=VectorSpace(k,11)defpad(ll,n):# pad the list ll with 0's to make it have length nx=len(ll)ifx<n:returnll+(n-x)*[0]else:returnll[0:n]defvectorize(p,n):# make a vector of length n out of a polynomialcoeffs=p.coefficients(sparse=False)returnV(pad(coeffs,n))defmkCode(p):# vectorize the polynomial T^i * p and use the vectors as a basis for the code C# I'm assuming deg p = 5...returnV.subspace([vectorize(T^i*p,11)foriinrange(6)])C1=mkCode(g)C2=mkCode(h)defweight(v):r=[xforxinvifx!=0]returnlen(r)defmin_distance(D):# brute-force computation of minimal distance of Dreturnmin([weight(v)forvinDifv!=0])[min_distance(c)forcin[C1,C2]]