On Tue, May 15, 2012 at 08:33:23AM -0700, tvn wrote: > I am wondering if Sage has some functions to generate the below > given N,K (both are non-neg ints), return a set of tuples (n1...nk) > such that ni >= 0 and sum(ni)= N. > > So if N=5,k=2, then there are 6 tuples (5,0) (4,1) ... (0,5) . > > Is there a name for this problem ?
sage: C = IntegerVectors(5,2) sage: C.list() [[5, 0], [4, 1], [3, 2], [2, 3], [1, 4], [0, 5]] sage: C.cardinality() 6 > what is the # of tuples for the given N,K ? Use introspection to find the class of C: sage: C?? and look up the cardinality method. Then prove the formula :-) Kind regards, Nicolas -- Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net> http://Nicolas.Thiery.name/ -- 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.