Really, really small HP-15C Mini-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: Really, really small HP-15C Mini-Challenge (/thread-48699.html) Really, really small HP-15C Mini-Challenge - Valentin Albillo - 12-09-2003 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. Re: Really, really small HP-15C Mini-Challenge - V-PN - 12-09-2003 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 Re: Really, really small HP-15C Mini-Challenge - Valentin Albillo - 12-09-2003 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. Re: Really, really small HP-15C Mini-Challenge - Brent - 12-09-2003 LBL A ROLL D SWAP ROLL U - ROLL D - ROLL U R-P RTN Having Problems getting 8 steps! Re: Really, really small HP-15C Mini-Challenge - Nelson M. Sicuro (Brazil) - 12-09-2003 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, Nelson HP-32S Version - Nelson M. Sicuro (Brazil) - 12-09-2003 If my logic is correct, there is the 32S version: ```LBL A CMPLX- x,y->angle,r RTN ``` Even smaller.... Re: Really, really small HP-15C Mini-Challenge - V-PN - 12-09-2003 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?) Re: HP-32S Version - V-PN - 12-09-2003 I *think* that it is:.....LBL A.....I.....Rv.....I.....R^ .....-.....->P.....RTN 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! [VPN] Re: Really, really small HP-15C Mini-Challenge - Valentin Albillo - 12-09-2003 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. Re: HP-32S Version - Nelson M. Sicuro (Brazil) - 12-09-2003 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! Nelson 4 steps on 32SII - Tizedes Csaba - 12-09-2003 Like a virgin: (I just turned on my computer, launching on the Forum and dont see anithing else): HP32SII version: ```LBL D CMPLX- y,x->fi,r RTN CK=A11B 6 bytes ``` Csaba Without complex functions on 32SII - Tizedes Csaba - 12-09-2003 ```LBL A CL summa summa - roll down roll down summa + summa y summa x y,x->fi,r RTN CK=145A 15 bytes, 10 steps ``` Csaba Re: Without complex functions on 32SII - Valentin Albillo - 12-09-2003 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. I haven't got time... ;( - Tizedes Csaba - 12-09-2003 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... Csaba Without complex functions on 15C - Nelson M. Sicuro (Brazil) - 12-09-2003 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. Re: Really, really small HP-15C Mini-Challenge - RMillán - 12-09-2003 ABS instead of ->P? Re: Really, really small HP-15C Mini-Challenge - Victor Koechli - 12-10-2003 The shortest I can think of is: ```LBL A I RDN I RUP - ABS CF 8 RTN ``` 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 Solved ! - Valentin Albillo - 12-10-2003 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. 7 step 41c version - Renato - 12-10-2003 ```Tested with P41CX on my Tungsten-E 001 LBL 002 ST - Z 003 RDN 004 ST - Z 005 RDN 006 R-P 007 RTN ``` Very good indeed ! :-) [NT] - Valentin Albillo - 12-10-2003 Best regards from V.