by "Curtis A. Jones" <curtis_jones@[EMAIL PROTECTED]
>
Mar 16, 2008 at 01:41 PM
Doug,
A function I called SNS (select number of stamps?) takes a vector of
stamp values as the left argument and the total desired value as the
right argument and gives columns with the number of stamps of each
value. One would usually pick the column with the smallest sum.
e.g.
0.01 0.02 0.05 SNS 0.07
0 1 2 3 5 7
1 3 0 2 1 0
1 0 1 0 0 0
Here's the listing using APL2ASCII. I split lines [1] and [6], so you
may have to put them back together for APL2ASCII to assemble the
function.
The technique is a fairly brute force application of outer product,
but it's been useful. Curtis
{del}SNS[#]{del}
{del}
[0] Z{<-}A SNS B;C;D;#IO
[1] @[EMAIL PROTECTED]
Select number of stamps of denominations A
for total value B.
[2] @[EMAIL PROTECTED]
CAJ 19 DEC 1987.
[3] @[EMAIL PROTECTED]
Maximum number of stamps of each denomination.
[4] C{<-}{floor}B{divide}A{<-},A
[5] #IO{<-}D{<-}0
[6] L2:{->}(({rho}A){<=}{rho}{rho}D{<-}D{jot}.+
A[{rho}{rho}D]{times}{iota}1+C[{rho}{rho}D]){drop}L2
[7] Z{<-}({rho}D){represent}(,D=B)/{iota}{times}/C+1
{del} 1995-01-25 23.04.00 (GMT-7)