HP Forums
More a curiosity than a challenge... - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: More a curiosity than a challenge... (/thread-29390.html)



More a curiosity than a challenge... - Vieira, Luiz C. (Brazil) - 03-10-2003

Hi;

One curiosity (or chalenge): given three numbers A, B and C in the stack (X-, Y- and Z- registers) what's the shortest way to get (A+B+C), A, B and C in any order in the stack by using only the stack registers and stack manipulations?

Before   After  or     or    or...

X A A A+B+C A
Y B B A A+B+C
Z C C B -
T - A+B+C - C

L - - C B

I know an easy way with the HP42S:

ENTER
RCL - ST Z
RCL - ST T

or in an HP41:

ENTER
R^ (ROLL-UP)
ST+ Y
R^ (ROLL-UP)
ST+ Z

but I would like to know the shortest way to do it in, say, a Voyager, or in an HP32SII, or in an HP12C. Restrictions are the calculator's resources themselves. Any clues?

This is intented to activate some stand-by, RPN-mode, stack-simulation areas of contributors' brains. And, of course, I want to know a better, shortest way to do it.

Hope you like it.

Luiz C. Vieira - Brazil


Oops!! Typo.. - Vieira, Luiz C. (Brazil) - 03-10-2003

Hi;

the HP42S procedure is:

ENTER
RCL + ST Z
RCL + ST T

Forgive me!

Luiz C. Vieira - Brazil