Identifier
Mp00000:
Integer partitions
—Decrement the largest parts of a partition⟶
Integer partitions
Description
For partitions with the largest part > 1, we decrement all the largest parts by 1 and increment the other (largest possible) parts to obtain the resulting partition of the same number. The resulting partition may grow in length as needed.
Sage code
def increment_first_part(p,length=None): ''' Increment the part with the smallest index `i` > 1 in partition `p` when such `i` exists. When `length` is given it bound the length of the resulting partition. Otherwise, it may become longer than `p`. ''' q = list(p) + [0]*(0 if length is None else length-len(p)) try: # find smallest index i>0 such that q[i] can be incremented i = next(i for i in range(1,len(q)) if q[i]<q[i-1]) q[i] += 1 except StopIteration: if length is None: # grow length of the partition q.append(1) return Partition(q) def mapping(p): if len(p)==0 or p[0]==1: return p m0 = max(i+1 for i in range(len(p)) if p[i]==p[0]) # multiplicity of part p[0] q = list(p) for i in range(m0): q[i] -= 1 for i in range(m0): q = increment_first_part(q) return Partition(q)
Created
Jul 02, 2025 at 19:45 by Max Alekseyev
Updated
Jul 02, 2025 at 19:45 by Max Alekseyev
4 Jul 10:30