Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To find the number of ways to divide <code>(m+n+p)</code> items in group of <code>m,n,p</code>is first to divide the set in groups of <code>m</code> and then each of these groups divide by <code>n</code> followed by divide by <code>p</code>.</p> <p>Now of ways to divide (m+n+p) items in groups of (n+p) is </p> <p>==> <sup>(n+m+n)</sup>C<sub>n+p</sub></p> <p>==> (m+n+p)!/(m!*(n+p)!)</p> <p>Now of ways to divide (n+p) items in groups of n is </p> <p>==> <sup>(n+p)</sup>C<sub>n</sub></p> <p>==> (n+p)!/(n!*(p)!)</p> <p>so <sup>(n+m+n)</sup>C<sub>m</sub> * <sup>(n+p)</sup>C<sub>n</sub> = (m+n+p)!/(m!*(n+p)!) * (n+p)!/(n!*(p)!)</p> <p>==> (m+n+p)!/(m!*n!*p!)</p> <p>To do the combinations we can use <a href="http://docs.python.org/library/itertools.html#itertools.combinations" rel="nofollow">itertools.combinations</a></p> <p>Given m=4,n=3,p=2</p> <p>Divide the Group into (n+p) = 5 items</p> <pre><code>&gt;&gt;&gt; g1=(x for x in itertools.combinations(xrange(9),5)) </code></pre> <p>Note:: You can leave it as a generator.</p> <p>Divide each of these groups into subgroup of n items = 3 items</p> <pre><code>&gt;&gt;&gt; groups=[(x,tuple(set(g)-set(x))) for g in g1 for x in itertools.combinations(g,3)] </code></pre> <p>Note:: tuple(set(g)-set(x)) would give you elements not is x i.e. the other part of the group</p> <p>Size of the Group is</p> <pre><code>&gt;&gt;&gt; len(groups) 1260 &gt;&gt;&gt; </code></pre> <p>Now Validate</p> <pre><code>&gt;&gt;&gt; factorial(9)/(factorial(2)*factorial(3)*factorial(4)) 1260 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload