Mailing List Archive: 49091 messages

[REBOL] Re: How to...? Convert Date of Birth to Age

From: joel:neely:fedex at: 27-Oct-2002 17:48

```

> I would say the "largest" ? (but that doesn't matter, of course,
> because everybody can see, what you mean)
>

Hmmm...  I need to think out loud more loudly!  ;-)

The term "smallest" was stuck in my head because I also realized
that the algorithm could be considered a reasonably near cousin
of the standard solution of the "change-maker's problem":

For some currency X assume that you have an adequate supply of
bills and/or coins in denominations of

X50.00 X20.00 X10.00 X5.00 X1.00 X0.50 X0.25 X0.10 X0.05 X0.01

(e.g. in a cash drawer) and you are asked to provide some
amount of money less than X100.00 (e.g. change to a customer
for a purchase) using as the minimum number of bills/coins.

The "smallest" solution (smallest number of pieces of money) can be
had by iterating across the denominations from largest to smallest
and counting out the maximum number of each denomination that does
not exceed the remaining balance, deducting each bill/coin from the
remaining balance as dispensed.  Ergo, "smallest" in the sense of
minimizing the total of the (three, in this case) elements in the
result block.

The quotation marks were intended as an (obviously inadequate) hint
that normal LESSER? comparison was not the metric in mind.

Sorry for not being more clear!

-jn-

--
; Joel Neely                             joeldotneelyatfedexdotcom
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]
```