#C20.txt, April 5, 2021 Help20:=proc(): print(`Box(Dim), HamD(u,v) , Nei(S,v), MaxHD(S), Hao(Dim,J)`):end: #Box(Dim): inputs a list of pos. integers DIM #and outputs the set of vectors #{1,2,3.., Dim[1]} x....x {1,2,... Dim[nops(Dim)]} Box:=proc(Dim) local d,Dim1, S,v, i: option remember: d:=nops(Dim): if d=0 then RETURN({[]}): fi: Dim1:=[op(1..d-1,Dim)]: S:=Box(Dim1): {seq(seq([op(v) , i ], i=1..Dim[d]), v in S)}: end: #HamD(u,v): The Hamming distance between vetor u and v HamD:=proc(u,v) local i, co: co:=0: for i from 1 to nops(u) do if u[i]<>v[i] then co:=co+1: fi: od: co: end: #Nei(S,v): inputs a set of vectors S and a vector v #outputs the number of members of S whose Hamming distance to v is 1 Nei:=proc(S,v) local co,w: co:=0: for w in S do if HamD(w,v)=1 then co:=co+1: fi: od: co: end: #MaxHD(S): inputs a set of vectors S and outputs the #max number of neighbors a member of S can have MaxHD:=proc(S) local v,m: if S={} then RETURN(FAIL): fi: max(seq(Nei(S,v), v in S)): end: with(combinat): #Hao(Dim,J): Inputs a list Dim, and an integer J between #1 and nops(Box(Dim)) and outputs #The champion, and the record in the competition #which subset of Box(Dim) with J elements has the minimimum degree Hao:=proc(Dim,J) local B,S,cha,rec,cand,hope1,i: B:=Box(Dim): S:=choose(B,J): cha:={}: cha:={S[1]}: rec:=MaxHD(S[1]): for i from 2 to nops(S) do cand:=S[i]: hope1:=MaxHD(cand): if hope1