CombinatorialCase010

From NARS2000
Revision as of 22:38, 29 April 2017 by WikiSysop (talk | contribs)
Jump to navigationJump to search

This case produces the L Combinations of R items.

  • L unlabeled balls (0), R labeled boxes (1), at most one ball per box (0)
  • Sensitive to ⎕IO
  • Count result is an integer scalar
  • Generated result is an integer matrix.

The count for this function is L!R.

For example:

If we have 2 unlabeled balls (●●) and 4 labeled boxes (1234) with at most one ball per box, there are 6 (↔ 2!4) ways to meet these criteria:

       
1 2 3 4
       
1 2 3 4
       
1 2 3 4
       
1 2 3 4
       
1 2 3 4
       
1 2 3 4

and, in general, it’s easy to see that this case solves the familiar problem of L combinations of R items.

The diagram above corresponds to

      010 1‼2 4
1 2
1 3
1 4
2 3
2 4
3 4
      ⍝ Combinations
      ⍝ Unlabeled balls, labeled boxes, ≤1 #bpb
      3!5
10
      010‼3 5
10
      010 0‼3 5
10
      ⍴010 1‼3 5
10 3
      010 1‼3 5
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5

In general, this case is related to that of Multisets (011) and Compositions (012) via the following identities:

010 1‼L R ↔ (011 1‼L,R-L-1)+[⎕IO+1] 0..L-1
011 1‼L R ↔ (010 1‼L,L+R-1)-[⎕IO+1] 0..L-1

010 1‼L R ↔ +\0 ¯1↓012 1‼⍠1 R L+1
012 1‼L R ↔ ¯2-\(010 1‼⍠1 R L-1),L

where ‼⍠1 uses the Variant operator to evaluate in origin 1.