CombinatorialCase000/100

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

L Pigeons into R holes

Cases 000 and 100 are both trivial.

  • L unlabeled (0) or labeled (1) balls into R unlabeled boxes (0), at most one per box (0)
  • Not ⎕IO-sensitive
  • Counted result is a Boolean scalar
  • Generated result is a Boolean matrix.

The count for this function is L≤R.

If L>R, then there is no answer, or more accurately, the result is an empty matrix of shape 0 R. If L≤R, then the result is a one-row matrix with L leading 1s and the rest 0s. Combining these two cases yields a result of ((L≤R) R)⍴R↑L⍴1.

For example:

If we have 3 unlabeled balls (●●●) and 5 unlabeled boxes with at most one ball per box, there is only 1 (↔ 3≤5) way to meet these criteria:

 
 
 
 
   
 
   

as well as

 
 
 
   
 
   
 

The diagram above corresponds to

      000 1‼3 5
1 1 1 0 0

      ⍝ L pigeons into R holes
      ⍝ Unlabeled balls & boxes, ≤1 #bpb
      000 1‼4 5
1 1 1 1 0