MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

compositions with the restricted set of integers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105143] compositions with the restricted set of integers
  • From: michael partensky <partensky at gmail.com>
  • Date: Sun, 22 Nov 2009 06:10:01 -0500 (EST)

 IntegerPartitions has a useful option restricting the values of partitions.
For example, IntegerPartitions[6,2,{1,2,3,4,5,6}] . Does it exist for
Compositions?

What I am looking for is a substitute for  a lengthy and inefficient
approach described below. We through n dice.  How many outcomes
*outs*correspond to the face total equal
*sum*?
I am aware about the recursive approach, but prefer to describe it in terms
of integer partitioning (or compositions).
*Here is my intellectually insulting solution:*

outs[sum_, thr_] :=
  Length[Flatten[
    Permutations /@
     Cases[IntegerPartitions[sum, thr, {1, 2, 3, 4, 5, 6}],
      Table[_, {thr}]], 1]];

Mapping with  permutations seems especially silly.
Is there a version of Compositions with the similar restrictive option ({1,
2, 3, 4, 5, 6})?
I would appreciate any other suggestions as well.

Thanks
Michael



  • Prev by Date: Re: Batch save mode?
  • Next by Date: Re: Batch save mode?
  • Previous by thread: Information about method and parameters used in NDSolve
  • Next by thread: Re: compositions with the restricted set of integers