#OK to post homework #Wanying Rao, 03/14/2021, Assignment 14 #1 BZ := proc(L,j) local t,n,L1: t := nops(L): n := sum(L[k],k=1..nops(L))+(3*j^2+j)/2: if t+3*j >= L[1] then L1 := [t+3*j-1,op(L-[1$t])]: RETURN([L1,j-1]): fi: if t+3*jDIS(n) Glashier := proc(L) local k,L1,i,j,m,b: L1 := []: for i in convert(L,set) do m := 0: for j from 1 to nops(L) do if L[j] = i then m := m+1: fi: od: b := convert(m,binary): for k from 1 to length(b) do if b mod 10^k = 10^(k-1) then b := b-10^(k-1): L1 := [op(L1),i*2^(k-1)]: fi: od: od: RETURN(L1): end: #DIS(n)->ODD(n) InvGlashier := proc(L) local L1,L2,i,j: L1 := L: L2 := []: for i from 1 to nops(L) do j := 0: while L1[i] mod 2 = 0 do L1[i] := L1[i]/2: j := j+1: od: L2 := [op(L2),L1[i]$2^j]: od: RETURN(L2): end: #3 #ODD(n)->DIS(n) Sylverster := proc(L) local i,m,L1,L2: if L=[] then RETURN([]): fi: if convert(L,set) = {1} then RETURN([nops(L)]): fi: m := 0: for i from 1 to nops(L) do if L[i]=1 then m := m+1: fi: od: L1 := Sylverster(L[2..(nops(L)-m)]-[2$(nops(L)-m-1)]): L2 := [(L[1]-1)/2 + nops(L), (L[1]-1)/2 + nops(L)-m - 1, op(L1)]: end: #DIS(n)->ODD(n) InvSylverster := proc(L) local L1,L2,a1,m: if L = [] then RETURN([]): fi: if nops(L) = 1 then RETURN([1$L[1]]): fi: L1 := InvSylverster(L[3..nops(L)]): a1 := L[2]-nops(L1): m := L[1]-L[2]-1: L2 := [2*a1+1,op(L1+[2$nops(L1)]),1$m]: RETURN(L2): end: