# OK to post homework # Lucy Martinez, 03-06-2026, Assignment 13 with(combinat): # Question 1: # A partition is d-super-distinct if the difference between two consecutive parts # is >=d. The usual distinct partitions are 1-distinct # Write a procedure IsSuperDistinct(L,d) that inputs a partition # (a member of Par(n), written in the usual way as weakly decreasing list of integers) # and outputs true iff for all i, between 1 and nops(L)-1, L[i]-L[i+1]>=d # Using this, write a procedure SuperDistinctPars(n,d) that outputs the subset of Par(n) # consisting of d-super-distinct partitions IsSuperDistinct:=proc(L,d) local m,i: m:=nops(L): for i from 1 to m-1 do if L[i]-L[i+1]< d then RETURN(false): fi: od: true: end: SuperDistinctPars:=proc(n,d) local S,S1,s: S:=Par(n): S1:={}: for s in S do if IsSuperDistinct(s,d) then S1:=S1 union {s}: fi: od: S1: end: #Question 2: # Write a procedure ParMod(n,a,A) that inputs a positive integer n, # another positive integer a, and a subset, A, of {0,1, .., a-1} # and outputs the subset of Par(n) consisting of those partitions # all whose entries mod a belong to A. ParMod:=proc(n,a,A) local S,S1,L: S:=Par(n): S1:={}: for L in S do if ParMod1(L,a,A) then S1:=S1 union {L}: fi: od: S1: end: #ParMod1(L,a,A): given a partition L, an integer a, a subset A of {0,1,...,a-1} # outputs true if all the entries L[i] in the partition L satisfy the property that # L[i] mod a belong to the set A ParMod1:=proc(L,a,A) local s: for s in L do if not member(s mod a,A) then return(false): fi: od: true: end: #Question 3: # What OEIS sequence is {nops(SuperDistinct(n,2)) }? # ANSWER: A003114 - Number of partitions of n into parts 5k+1 or 5k+4 # Here are the first elements of the sequence: # [1, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 14, 17, 19, 23, 26, 31] # # What OEIS sequence is {nops(ParMod(n,5,{1,4})) }? # ANSWER: A003114 - Number of partitions of n into parts 5k+1 or 5k+4 # Here are the first elements of the sequence: # [1, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 14, 17, 19, 23, 26, 31] # These are the same sequences!!! #Question 4: Eventually nops(SYT(L)) will be impractical, since the sets SYT(L) gets very big. # Adapt procedure SYT(L) to write a procedure NuSYT(L) # that inputs an integer partition L, and outputs the NUMBER of Standard Young Tableaux of shape L. # For example NuSYT([2,2]); should output 2, and NuSYT([3,3,3]); should output 42. NuSYT:=proc(L) local i,k,n,L1,co: option remember: k:=nops(L): n:=add(L[i],i=1..k): if k=0 then return(1): fi: co:=0: #now we look for all the legal rows where the element n can be placed for i from 1 to k-1 do if L[i]>L[i+1] then L1:=[op(1..i-1,L),L[i]-1,op(i+1..k,L)]: co:=co+NuSYT(L1): fi: od: if L[k]>1 then L1:=[op(1..k-1,L),L[k]-1]: co:=co+NuSYT(L1): else L1:=[op(1..k-1,L)]: co:=co+NuSYT(L1): fi: co: end: ##################################From previous classes: # C13.txt, March 05, 2026 Help13:=proc(): print(`ParN(n,k), PFG(L), SYT(L), PYT(Y)`): end: #ParN(n,k): outputs the partitions of n for which the first part equal to k ParN:=proc(n,k) local s,S,T: S:=Par(n): T:={}: for s in S do if s[1]=k then T:=T union {s}: fi: od: T: end: #PFG(L): The Ferrers graph of the partition L PFG:=proc(L) local i: for i from 1 to nops(L) do lprint(1$L[i]): od: end: #SYT(L): the set of standard young tableaux of shape L SYT:=proc(L) local i,s1,k,n,S,L1,S1: option remember: k:=nops(L): n:=add(L[i],i=1..k): if k=0 then return({[]}): fi: S:={}: #now we look for all the legal rows where the element n can be placed for i from 1 to k-1 do if L[i]>L[i+1] then L1:=[op(1..i-1,L),L[i]-1,op(i+1..k,L)]: S1:=SYT(L1): S:=S union {seq([op(1..i-1,s1) , [op(s1[i]),n], op(i+1..k,s1)] ,s1 in S1)}: fi: od: if L[k]>1 then L1:=[op(1..k-1,L),L[k]-1]: S1:=SYT(L1): S:=S union {seq([op(1..k-1,s1) , [op(s1[k]),n]],s1 in S1)}: else L1:=[op(1..k-1,L)]: S1:=SYT(L1): S:=S union {seq([op(1..k-1,s1) , [n] ],s1 in S1)}: fi: S: end: #PYT(Y): prints the standard Young Tableaux Y PYT:=proc(Y) local i: for i from 1 to nops(Y) do lprint(op(Y[i])): od: end: ################################### # C12.txt, March 02, 2026 Help12:=proc(): print(`Park(n,k), Par(n)`): end: #Park(n,k): The set of partitions of n into exactly k parts Park:=proc(n,k) local S,k1,S1,s1: option remember: if n