Hi Alex,

How about

def add_rho(mu,k):
    mu = (mu+[0]*k)[:k]
    return [mu[i]+k-i for i in range(k)]

def partitions_with_distinct_parts(N,k):
    M = Integer(N-(k+1)*k/2)
    P = Partitions(M,max_length=k)
    return [add_rho(p,k) for p in P]

sage: partitions_with_distinct_parts(10,3)
[[7, 2, 1], [6, 3, 1], [5, 4, 1], [5, 3, 2]]

Best,

Anne

On 12/13/12 8:48 PM, Alex Ghitza wrote:
> Hi,
> 
> For fixed positive integers k and N, I'd like to compute the list of 
> partitions
> 
> N = n_1 + n_2 + ... + n_k
> 
> such that n_1 < n_2 < ... < n_k.
> 
> What's the best (i.e. fastest) way to achieve this?
> 
> 
> --
> Best,
> Alex
> 
> --
> Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne
> http://aghitza.org

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to