Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Apl > Re: Need an Alg...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 15 Topic 970 of 1019
Post > Topic >>

Re: Need an Algorithm

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)




 15 Posts in Topic:
Need an Algorithm
gwhite@[EMAIL PROTECTED]   2008-03-16 15:12:37 
Re: Need an Algorithm
"jk" <*axy*@  2008-03-16 15:42:19 
Re: Need an Algorithm
gwhite@[EMAIL PROTECTED]   2008-03-16 18:41:09 
Re: Need an Algorithm
"graham" <h2  2008-03-16 14:51:30 
Re: Need an Algorithm
gwhite@[EMAIL PROTECTED]   2008-03-16 18:46:46 
Re: Need an Algorithm
gwhite@[EMAIL PROTECTED]   2008-03-16 19:05:44 
Re: Need an Algorithm
Don Wiss <donwiss@[EMA  2008-03-16 14:32:42 
Re: Need an Algorithm
Don Wiss <donwiss@[EMA  2008-03-16 13:00:46 
Re: Need an Algorithm
gwhite@[EMAIL PROTECTED]   2008-03-16 18:40:08 
Re: Need an Algorithm
Don Wiss <donwiss@[EMA  2008-03-16 14:27:37 
Re: Need an Algorithm
Don Wiss <donwiss@[EMA  2008-03-20 19:41:18 
Re: Need an Algorithm
gwhite@[EMAIL PROTECTED]   2008-03-21 00:57:42 
Re: Need an Algorithm
"Curtis A. Jones&quo  2008-03-16 13:41:13 
Re: Need an Algorithm
"James J. Weinkam&qu  2008-03-17 17:14:55 
Re: Need an Algorithm
sethb@[EMAIL PROTECTED]   2008-03-20 19:22:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 9:19:15 CDT 2008.