CombinatorialCase000/100: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 91: Line 91:


       ⍝ L pigeons into R holes
       ⍝ L pigeons into R holes
       ⍝ Unlabeled balls & boxes, ≤1 #bpb
       ⍝ Unlabeled balls & boxes, ≤1 # Balls per Box
       000 1‼4 5
       000 1‼4 5
1 1 1 1 0</pre></apll>
1 1 1 1 0</pre></apll>

Revision as of 01:58, 30 April 2017

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 # Balls per Box
      000 1‼4 5
1 1 1 1 0