def last_lexical(q, n):
""" Find the last lexical (i.e. most even) partition of q having n parts
q : the total sum of the partition
n : number of parts in the partition
j : place holder """
test_qnk(q, n)
b, _remainder = divmod(q, n)
partition = [b] * n # largest list of integers whose sum <= n
# put any remainder on the first element
partition[0] += _remainder
return partition
Proposed new routine: