The Museum of HP Calculators

HP Forum Archive 17

[ Return to Index | Top of Index ]

quick mini-challenge for 12c
Message #1 Posted by Don Shepherd on 26 May 2007, 5:37 p.m.

All right, write the shortest possible program for the 12c that does this: You input the sum of 2 numbers, the difference of the same 2 numbers, and the program calculates and displays the 2 numbers.

      
Re: quick mini-challenge for 12c
Message #2 Posted by Gerson W. Barbosa on 26 May 2007, 8:54 p.m.,
in response to message #1 by Don Shepherd

01- STO 0
02- +
03- 2
04- /
05- ENTER
06- ENTER
07- RCL 0
08- -

Too many steps?

            
Re: quick mini-challenge for 12c
Message #3 Posted by Don Shepherd on 26 May 2007, 8:59 p.m.,
in response to message #2 by Gerson W. Barbosa

Gerson, your program displays the smaller of the two numbers, but not the larger (if I entered it correctly).

                  
Re: quick mini-challenge for 12c
Message #4 Posted by Gerson W. Barbosa on 26 May 2007, 9:06 p.m.,
in response to message #3 by Don Shepherd

Sorry, I forgot to mention the other number is in register Y.

                        
Re: quick mini-challenge for 12c
Message #5 Posted by Don Shepherd on 26 May 2007, 9:07 p.m.,
in response to message #4 by Gerson W. Barbosa

Yes, I saw that after I replied. I've got a 7 line program that pauses after the first number then displays the second.

                              
Re: quick mini-challenge for 12c
Message #6 Posted by Gerson W. Barbosa on 26 May 2007, 9:23 p.m.,
in response to message #5 by Don Shepherd

Something like this?

01 -
02 LSTx
03 x<>y
04 2
05 /
06 PSE
07 +
                                    
Re: quick mini-challenge for 12c
Message #7 Posted by Don Shepherd on 26 May 2007, 9:27 p.m.,
in response to message #6 by Gerson W. Barbosa

Actually, more like your first one, except a little different:

01 STO 1
02 -
03 2
04 /
05 PSE
06 RCL 1
07 +

But yours works too. It's always great to see another mind at work!

                                          
Re: quick mini-challenge for 12c
Message #8 Posted by Gerson W. Barbosa on 26 May 2007, 9:37 p.m.,
in response to message #7 by Don Shepherd

I'm glad I didn't submit my first try at your mini-challenge. A very long 9-step program :-)

Regards,

Gerson.

                                                
Re: quick mini-challenge for 12c
Message #9 Posted by Don Shepherd on 26 May 2007, 11:28 p.m.,
in response to message #8 by Gerson W. Barbosa

Gerson, don't feel bad! My first try was 14 steps, but I knew it could be improved. My goal was to get to 8 or fewer steps, since the first 8 steps are "free" (that is, you don't lose any registers). Being a minimalist, I am intrigued by fitting a program in 8 steps on the 12c, if possible.

Thanks for your example.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall