ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 13 Jul 2015 06:14:52 -0500Seeking an efficient filter for partitions.https://ask.sagemath.org/question/27321/seeking-an-efficient-filter-for-partitions/From the docs:
sage: Partitions(4, max_part=2).list()
[[2, 2], [2, 1, 1], [1, 1, 1, 1]]
I find this parlance confusing. Obviously
the partition [1, 1, 1, 1] has no max part = 2. Be that as it may, I do want to filter those
partitions which greatest part is 2, so in the
example would return
[[2, 2], [2, 1, 1]].
What is the most efficient way to implement
P(n,k) = Partitions(n, MAX_PART=k)
where MAX_PART is defined in my sense?
Mon, 13 Jul 2015 04:38:26 -0500https://ask.sagemath.org/question/27321/seeking-an-efficient-filter-for-partitions/Answer by Nathann for <p>From the docs:</p>
<pre><code>sage: Partitions(4, max_part=2).list()
[[2, 2], [2, 1, 1], [1, 1, 1, 1]]
</code></pre>
<p>I find this parlance confusing. Obviously
the partition [1, 1, 1, 1] has no max part = 2. Be that as it may, I do want to filter those
partitions which greatest part is 2, so in the
example would return </p>
<pre><code>[[2, 2], [2, 1, 1]].
</code></pre>
<p>What is the most efficient way to implement</p>
<pre><code>P(n,k) = Partitions(n, MAX_PART=k)
</code></pre>
<p>where MAX_PART is defined in my sense?</p>
https://ask.sagemath.org/question/27321/seeking-an-efficient-filter-for-partitions/?answer=27323#post-id-27323Would this work?
sage: Partitions(4, max_part=2,inner=[2]).list()
[[2, 2], [2, 1, 1]]
Mon, 13 Jul 2015 06:14:52 -0500https://ask.sagemath.org/question/27321/seeking-an-efficient-filter-for-partitions/?answer=27323#post-id-27323