On Sep 13, Bob Showalter said:

I need help with an algorithm. I'm writing a program that sends a repeated
pattern of requests to a service. Each request has a "weight" that controls
the relative frequency with which I need to send that particular request.

  foo => 1
  bar => 1
  qux => 6


  foo
  qux qux qux
  bar
  qux qux qux

Now I have only intervals of 0 or 1 between successive "qux", instead of an
interval of 2 as in the previous case.

As an extreme example, if I had a dozen requests with a weight of 1 and a
final request with a weight of 12, I would "starve" the highly-weighted
request until the first 12 had been sent.

The extreme cases are the easy ones, though. What I'd like to see are cases like:

  foo => 1
  bar => 2
  qux => 3
  baz => 4
  zip => 5

Once I know what the algorithm's outcome should be for something like that, I think I can develop it.

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to