> From: John Randall <[EMAIL PROTECTED]>
> 
> Oleg Kobchenko wrote:
> 
> >    ]phi=: -:1+%:5
> > 1.61803
> >    fc=: <.@((%:5) + phi&*) - 2:
> 
> Thanks, Oleg.  I was aware of this formulation.  I have
> 
> shift2=:3 : '_2+<.(%:5)+(-:>:%:5)*y'
> 
> I am most interested in a better version of z and, in general, how to do
> greedy algorithms in J.

I don't immediately see how the Fibonacci sum is greedy.

But here's a greedy Change:
http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Greedy/greedyIntro.htm

   change=: 2 -/\ (] - I. { [)^:([EMAIL PROTECTED])^:a:
   
   100 25 10 1 change 289
100 100 25 25 25 10 1 1 1 1


      
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to