In 1984 I wrote a little paperback called “Probility in APL”. I have been 
thinking about combination. So I translated three verbs to provide all the ways 
‘PNDQ’ or a penny, nickel,
 dime and quarter could be combined.
 
Possible outcomes:
po=: 13 :'|:y#:i.*/y'
po 2 2 2 2
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
Correction matrix: (array)
 
cm=: 13 :'(*/y)(#"0) 0,}:+/y' 
cm 2 2 2 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
All combinations as chafacters:
 
ac=: 13 :'((po + cm) ($y)#2){,'' '',.y'
ac 'PNDQ'
PPPPPPPP
NNNN NNNN
DD DD DD DD
Q Q Q Q Q Q Q Q
Each column is possible combination of the coins.
 
I’m interested to know a better way to get this conclusion.
 
Linda
 
 

Sent from my Verizon, Samsung Galaxy smartphone
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to