Hi all,

To spice the week a little, __exclusively__ for HP-15C owners and lovers (i.e., most of us; no other calculators allowed), here's a **New, Small HP-15C Challenge**. As always, it's very small yet it tries hard to be both entertaining and educational as well. But this time there are a couple novelties:

- You must have
*a real pro attitude*this time. You'll be "commissioned" to develop a solution*strictly*according to a series of compulsory requirements, and you must deliver, as in real life. - There's a (small) Prize awarded this time to the person who writes the best routine which unfailingly meets all specifications. 'Best' is intended to mean the routine is as short, fast, and uses the least resources as possible. If several solutions are equally deserving, all with be awarded the prize, myself being the final and sole judge.

The (small) Prize is your choice of a complete, __very
high-quality__ scan of your preferred

*rare*vintage HP brochure to choose among these three:

HP-65 brochure (in English, rare!)You can click the above links to see (purposely low-quality, lo-res) samples of all three. The scanned brochures themselves are

HP-55 brochure (in Spanish, very rare!!)

HP-01 brochure (in French, extremely rare!!!)

__marvelous__,

__large__,

__hi-res scans__,

__multiple pages__for each brochure, to be delivered to you electronically. They're certainly a pleasure to behold and read (though it also makes you a little sad and nostalgic to see what superb products and marketing brochures HP produced in its prime ...)

Even if you're not (!?) that interested in the scanned brochures, have a go at the Challenge. Though it seems simple enough, you'll quickly realize it's far from trivial to come up with even a working version according to the specifications, let alone an optimum one.

**The Challenge**

The owner of a small business wants, given a certain discount percentage rate

between 10.00% and 99.99% (both included), to compute both discounted amounts

from a series of non-discounted amounts and vice versa. She also wants to be able

to total both types of amounts for a series of conversions, plus be able to

specify the percentage rate at any time.

To that effect she's commissioned you to write a routine (LBL A ... RTN) for

her trusty HP-15C, which will be called either from the keyboard or from some

other main program, and must *EXACTLY* meet the following specifications, to-the-letter.

**To specify the percentage rate**(P), your routine will be called with the

percentage (between 10.00% and 99.99%) in the X register, will

likely store it somewhere else for later computations, and must

return with that same value unchanged in the X register, like this:

To set a 10.00% discount:

10

**[A]**-> 10.0000

**To convert non-discounted amounts to discounted amounts**, your routine

will be called with matrix C (which will hold a certain number of non-discounted amounts, arbitrary dimensions) in the X register.

. Your

routine must replace them in-place with the discounted amounts and return

with said matrix C in the X register, like this:Assuming that P = 10.00% and with C = (20, 30, 50), to compute the

discounted amounts:

RCL MATRIX C

where now C holds the discounted amounts, C = (18, 27, 45)**[A]**-> [C 1 3]

**To convert discounted amounts to non-discounted amounts**, your routine

will be called with matrix D (which will hold a certain number of discounted amounts, arbitrary dimensions) in the X register. Your routine must

replace them in-place with the non-discounted amounts and return with

said matrix D in the X register, like this:Assuming that P = 10.00% and with D = (36, 63, 81), to compute the

original, non-discounted amounts:

RCL MATRIX D

where now D holds the original, non-discounted amounts, D= (40, 70, 90)**[A]**-> [d 1 3]

**To totalize the discounted amounts in matrix C to the grand totals stored**, your routine must expect matrix C to be in Y and matrix E

in matrix E

to be in X, like this:

RCL MATRIX C, RCL MATRIX E

Assuming C = (18, 27, 45) and that E was (10, 20, 30), E is now (28, 47, 75)**[A]**-> [E 1 3]

**To totalize the original, non-discounted amounts in matrix D to the grand**, your routine must expect matrix D to be in Y and matrix E

totals in matrix E

to be in X, like this:

RCL MATRIX D, RCL MATRIX E

Assuming D = (40, 70, 90) and that E was (15, 20, 25), E is now (55, 90, 115)**[A]**-> [E 1 3]

**Notes:**

- in (4) and (5) above, notice that clearing matrix E before totalling is *not* the

responsibility of your routine. This will be done in the calling program

or from the keyboard [0, STO MATRIX E] if desired, it's not a functionality

that your routine must implement. - you must not assume that the stack (X,Y,Z,T,Last X) will hold any specific

contents before calling your routine other than the exact required parameters

specified above. Same goes for storage registers' contents, flags setting or modes (except for the place where you stored the percentage rate, which is assumed to still be there, of course). - you must not assume any specific storage register allocation [DIM (i)], so your routine

must work on the assumption that only the permanently storage registers are

allocated. - and last, but certainly not least, it should be clear by now that

LBL A is the*one and only*entry point to your routine. The calling

program will always use**GSB A**to invoke all your routine's functionalities

or else**[A]**will be used from the keyboard. Your routine must then assume

that it will always be entered at LBL A, with the required parameters on

the stack as per the desired function's specifications.It shall also assume that all variables and matrices are named

*exactly*

as specified and contain the specific kinds of amounts or totals described above.

Well, let's see if you're up to the task. Of course, the least resources

your routine uses, the better. There's a solution fulfilling all specified

requirements in 24 program steps or less (including LBL A ... RTN), which I will post after the Challenge is over, within a few days. Hope you'll enjoy it and ...

Best regards from V.