Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Combinatorics problem.

by Laurent_R (Canon)
on Dec 11, 2015 at 07:35 UTC ( [id://1149982]=note: print w/replies, xml ) Need Help??


in reply to Combinatorics problem. (Updated with more info.)

You may want to try Algorithm::Combinatorics or Math::Combinatorics CPAN modules (or some other CPAN modules on the subject).

Or are you looking for a way to do it yourself in Perl?

Replies are listed 'Best First'.
Re^2: Combinatorics problem.
by BrowserUk (Patriarch) on Dec 11, 2015 at 07:58 UTC
    You may want to try Algorithm::Combinatorics

    I use Algorithm::Combinatorics all the time, but you have to work out which generator, or combination of generators to use for each particular problem, and this one is eluding me.

    Also, I suspect that the sequence I need is a subset of one of the classical sequences (combs/perms/variations/partitions), and I would then need to filter the generated sequence, which can be grossly inefficient; so it may be better to program an algorithm that generates the sequence directly?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.

      You are looking for Composition_(combinatorics) and need to filter on the number of parts (after taking away 1 postcard for each pidgeon hole as suggested below). I have not found any code on CPAN for this. The bad news is that there are exponentially many compositions for a given number of postcards.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1149982]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 17:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found