crunch_this! has asked for the wisdom of the Perl Monks concerning the following question:
Hi
It's easy enough to get Integer::Partition working but what if I'm only interested in partitions that have an exact number of summands, like 3? & what if they all have to be distinct?
For partitions of 6, using
my $i = Integer::Partition->new(6); while (my $p = $i->next) { print join( ' ', @$p ), $/; }
Perl gives me
6But what if I were only interested in the ones with exactly 2 distinct summands, ie
5 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to restrict partitions
by toolic (Bishop) on Jan 18, 2014 at 02:58 UTC | |
by crunch_this! (Acolyte) on Jan 18, 2014 at 03:16 UTC | |
by toolic (Bishop) on Jan 18, 2014 at 03:29 UTC | |
by AnomalousMonk (Archbishop) on Jan 18, 2014 at 17:10 UTC | |
by crunch_this! (Acolyte) on Jan 19, 2014 at 03:11 UTC | |
by crunch_this! (Acolyte) on Jan 18, 2014 at 05:36 UTC | |
by choroba (Cardinal) on Jan 18, 2014 at 09:41 UTC | |
|
Re: How to restrict partitions
by hdb (Monsignor) on Jan 19, 2014 at 09:50 UTC | |
by crunch_this! (Acolyte) on Jan 20, 2014 at 02:27 UTC | |
by hdb (Monsignor) on Jan 20, 2014 at 07:10 UTC | |
|
Re: How to restrict partitions (NestedLoops)
by tye (Sage) on Jan 19, 2014 at 21:08 UTC | |
by crunch_this! (Acolyte) on Jan 27, 2014 at 00:20 UTC | |
by tye (Sage) on Jan 27, 2014 at 07:06 UTC | |
by crunch_this! (Acolyte) on Jan 27, 2014 at 21:13 UTC | |
|
Re: How to restrict partitions
by Laurent_R (Canon) on Jan 18, 2014 at 19:57 UTC | |
|
Re: How to restrict partitions
by danaj (Friar) on Oct 04, 2014 at 06:47 UTC |