Really, really small HP-15C Mini-Challenge


Hi all,

To brighten up your Tuesday morning, here's an HP-15C really, really small, "Quickie" Mini-Challenge:

Assume you've got two coordinate data points (x1,y1) and (x2,y2) preloaded into the stack exactly like this:

    T:  y2
Z: x2
Y: y1
X: x1

Try and write a routine (LBL ... RTN) which takes as input these coordinate
data points and returns as output the distance between them in X.

For the HP-15C, there's a solution in 8 program steps or
less (including LBL and RTN). See how much time does it take you to find (or even better) it ! :-)

Best regards from V.

Edited: 9 Dec 2003, 7:15 a.m.


If you would SWAP one of your many HP-15C to something, I would be pleased to try with (spoiling hint) Complex operations...

[VPN] - still without a HP-15C


VPN posted:

"If you would SWAP one of your many HP-15C to something, I would be pleased to try

No way. I already gave you a very good advice (IMHO) to get one. There's nothing more I can do for you in this regard, save giving you yet another well-meant advice: harassing everyone on this list to get an HP-15C (and other calculators) is not the way, methinks.

And by 'harassing' (not sure if this is the right word, no offence intended) I mean posting to this forum continual requests for all sort of trades, both explicitly and subtly. I think it would be far more proper and better forum netiquette to post them to the Classified section, don't you think ?

Best regards from V.



Having Problems getting 8 steps!


Me think you right: classified

BUT think about how pissed *YOU* would be without a single HP-15C, while everyone else seems to have more than enough and, instead of showing any Christmas spirit, the rich people just think that the poor beggers are harassing them...

[VPN] (tongue in cheek, because there is no cheese?)


I *think* that it is:

LBL A  42.21.11
I 42 25
Rv 33
I 42 25
R^ 43 33
- 30
->P 43 1
RTN 43 32

Please correct me if it is wrong...

Best regards,



If my logic is correct, there is the 32S version:


Even smaller....


I *think* that it is:.....LBL A.....I.....Rv.....I.....R^

Please correct me if it is wrong...Best regards,Nelson

If my logic is correct, there is the 32S version:

LBL A.....CMPLX-.....x,y->angle,r.....RTN

Even smaller

Seems like a happy owner of a HP-32S(II)/33S(42S?) will not need the HP-15C after all!



Yes, I'm a happy owner of *one* of each: 15C, 32S, 42S among others.

I begin to collect them in this year (aug/2003), before that I have only my 42S since 1989 (bought new).

My HP-15C I get here in Brazil for about US$45, NIB and my 32S for about US$50. If you search the web, you can get your own 15C.

Good luck!



Hi, Nelson:

Your solution is correct, congratulations, but there's another *slightly* faster one, in the same number of steps.

I don't want to spoil the fun by giving you any hints but think a little if you're doing something that's not needed and can be avoided, thus saving a little time :-)

Best regards from V.


ABS instead of ->P?


RMillan posted:

"ABS instead of ->P? "

Correct! That's the exact intended solution of the puzzle.
Conversion to polar form (->P) changes the complex stack like this:

      X:  (x, y)     ->P      X:  (mod, arg)
where mod = sqrt(x^2+y^2) and arg = arctan(y/x). We're only interested in the "mod" part, which is mathematically equal to the distance between both given data points, but we're not interested in the "arg" part at all, so it would be nice if we would find some way to avoid computing it at all.

This can be done using the ABS function, which returns the "mod" part alone, changing the complex stack like this:

      X:  (x, y)     ABS      X:  (mod, 0)
and so we get the distance we need but avoid computing the unneeded angle altogether, thus saving a little time. Thus, my original fast 8-step solution was this:
      01  LBL A 
02 I
03 Rdown
04 I
05 Rup
06 -
07 ABS
08 RTN

Congratulations for solving it, extensive to all of you who took interest in this mini-challenge. The idea was to show how the comprehensive HP-15C built-in function set can be used in non-obvious ways to achieve apparently unrelated computations. In this case, the use of complex functions allows a single "-" operation to perform (x2-x1) and (y2-y1) *simultaneously*, and then ABS computes the square root of the sum of their squares without computing the angle. This way you get done a lot of computation using just *two* steps, "-" and "ABS". Neat :-)

Best regards from V.


Like a virgin: (I just turned on my computer, launching on the Forum and dont see anithing else):

HP32SII version:


CK=A11B 6 bytes



CL summa
summa -
roll down
roll down
summa +
summa y
summa x

CK=145A 15 bytes, 10 steps



Very good, Csaba ! :-)

Can you find an 8-step solution in the HP-15C ? Nelson has found a perfectly correct solution in that number of steps, which can be improved slightly to make it run a little faster. Can you find both, Nelson's solution and my original, slightly faster one ? Or even improve on them ? :-)

Best regards from V.


Valentin: I'm so sorry, but I have got a designing work by tomorrow... (driving-gear..., the final 'cut' at University ;) )

But... I think with 'RCL summa+' that is will smaller...



I tested this on the 15C, and it shows the same result without using complex numbers:

(The only requirement is that the statistical registers must be cleared first with the 'Clear Sigma', this function cannot be in the program as it clears the stack!)

LBL A      42.21.11
Sigma- 43 49
Rv 33
Rv 33
Sigma+ 49
RCL Sigma 45 49
->P 43 1
RTN 43 32

Edited: 9 Dec 2003, 3:01 p.m.


The shortest I can think of is:

CF 8

which is still 9 steps. Of course you could omit CF 8 and leave the calc in complex mode.

The inevitable HP-48SX version is, of course
<< R-C ROT ROT R-C - ABS >>
which is only 6 commands as there are no labels or returns.

Ironically, the 32Sii's limited complex functionality (as compared to the HP-15C) makes the solution for this particular problem shorter than on the 15C :-(

Cheers, Victor


Tested with P41CX on my Tungsten-E
001 LBL
002 ST - Z
003 RDN
004 ST - Z
005 RDN
006 R-P
007 RTN


Best regards from V.

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Download] PrimeComm: Alternative small utility to upload/download programs to the HP Prime Erwin Ried 6 2,543 11-17-2013, 10:18 AM
Last Post: Erwin Ried
  [HP PRIME] small font bug display Damien 34 9,827 11-06-2013, 04:31 AM
Last Post: Nacho
  HPCC Mini Conference 2013 hugh steers 6 2,246 09-13-2013, 04:27 PM
Last Post: BruceH
  Picture from the Mini-HHC (LA) Geir Isene 11 3,113 07-07-2013, 01:06 PM
Last Post: Jim Horn
  A small but colourful bouquet ... Walter B 5 1,697 05-12-2013, 06:31 PM
Last Post: Bill Carter
  My birthday, so a little commemorative mini-challenge ! Valentin Albillo 43 8,405 03-07-2013, 03:44 AM
Last Post: Walter B
  WP 34S mini-challenge (B) Gerson W. Barbosa 17 4,618 12-27-2012, 04:39 PM
Last Post: Marcus von Cube, Germany
  Mini-challenge: HHC2012 RPL programming contest with larger input David Hayden 14 3,601 10-05-2012, 10:36 PM
Last Post: David Hayden
  HP41 / SY41CL Mini-B USB Power Connector (Module) Matt Kernal 5 3,193 07-08-2012, 06:23 PM
Last Post: Diego Diaz
  HP-15C (& LE!) 11-11-11 Mini-Challenge Valentin Albillo 28 6,933 11-14-2011, 08:12 AM
Last Post: Valentin Albillo

Forum Jump: