CombinatorialCase110: Difference between revisions
From NARS2000
Jump to navigationJump to search
(Created page with "This case produces <apll>L</apll>-'''Permutations''' (also called '''Partial Permutations''' or '''Sequences Without Repetition''') of <apll>R</apll> items, where when <apll>L...") |
No edit summary |
||
Line 6: | Line 6: | ||
* Generated result is an integer matrix. | * Generated result is an integer matrix. | ||
The count for this function is <apll>(!⍠(-L))R</apll> where <apll>(!⍠L)R</apll> calculates the [[Variant| | The count for this function is <apll>(!⍠(-L))R</apll> where <apll>(!⍠L)R</apll> calculates the [[Variant#Rising_and_Falling_Factorials|'''Rising and Falling Factorial''']]. | ||
For example: | For example: |
Revision as of 18:03, 29 April 2017
This case produces L-Permutations (also called Partial Permutations or Sequences Without Repetition) of R items, where when L=R produces the familiar permutations !R. The length of each permutation returned is always L.
- L labeled balls (1), R labeled boxes (1), at most one ball per box (0)
- Sensitive to ⎕IO
- Counted result is an integer scalar
- Generated result is an integer matrix.
The count for this function is (!⍠(-L))R where (!⍠L)R calculates the Rising and Falling Factorial.
For example:
If we have 3 labeled balls (❶❷❸) and 3 labeled boxes (123) with at most one ball per box, there are 6 (↔ (!⍠¯3)3 ↔ 3×2×1) ways to meet these criteria:
|
|
|
|
|
|
The diagram above corresponds to
110 1‼3 3 1 2 3 2 1 3 2 3 1 1 3 2 3 1 2 3 2 1 ⍝ Permutations of length L of R items ⍝ Labeled balls & boxes, ≤1 #bpb !3 6 110‼3 3 6 110 0‼3 3 6 ⍴110 1‼3 3 6 3 110 1‼3 3 1 2 3 2 1 3 2 3 1 1 3 2 3 1 2 3 2 1 110 1‼2 3 1 2 2 1 1 3 3 1 2 3 3 2 110 1‼1 3 1 2 3
A function to calculate the permutations of R items could be defined as
perm←{110 1‼⍵ ⍵}