The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

Capture the flag - HP-12C programming contest
Message #1 Posted by x34 on 11 Feb 2011, 12:01 p.m.

There are at least two flags on HP-12C: BEG/END and D.MY/M.DY. What the fastest ways to get these flags values? (and shortest also).

      
Re: Capture the flag - HP-12C programming contest
Message #2 Posted by gene wright on 11 Feb 2011, 12:59 p.m.,
in response to message #1 by x34

1)

10 second idea. Destroys values in financial registers.

0 FV 1 N 1 i 1 PV PMT 1 + X=0?

If condition true then it was in BEG mode, otherwise END mode.

2)

1.022 ENTER 1 CHS DATE INT 1 - x=0

will be true if mode was M.DY and will not if D.MY

I make no claims that these are anywhere near optimal, but they work.

            
Re: Capture the flag - HP-12C programming contest
Message #3 Posted by x34 on 11 Feb 2011, 3:06 p.m.,
in response to message #2 by gene wright

1) Being not acquainted with finance, is N "n" or "Nj"? 2) 14 steps, <5s in both modes. Wonderful! And unexpected (for me) VIEW/PSE effect.

                  
Re: Capture the flag - HP-12C programming contest
Message #4 Posted by gene wright on 11 Feb 2011, 3:09 p.m.,
in response to message #3 by x34

Oops. N should be lowercase n.

and an edit to the second set of instructions. Saves a step:

1.022 ENTER 1 CHS DATE LSTx - x=0

Edited: 11 Feb 2011, 3:11 p.m.

                        
Re: Capture the flag - HP-12C programming contest
Message #5 Posted by x34 on 11 Feb 2011, 3:17 p.m.,
in response to message #4 by gene wright

1) 11 steps. Less then 4 seconds!!! Das ist Fantastisch! My best was 15s with finance and three times in length (while destroying finance regs too). If finance regs (i use them only for polynomials) are destroyed, it could be used in the finishing part of any program to select output.

                              
Re: Capture the flag - HP-12C programming contest
Message #6 Posted by gene wright on 11 Feb 2011, 3:20 p.m.,
in response to message #5 by x34

1) May not be faster, but shorter:

0 FV 1 n 1 i 1 PV PMT FRC X=0?

                                    
Re: Capture the flag - HP-12C programming contest
Message #7 Posted by x34 on 11 Feb 2011, 3:34 p.m.,
in response to message #6 by gene wright

Gene, my HP12C says new program is actually a bit FASTER too :) Having read your articles on HP calcs for many years, I understand you are very experienced in programming them. Please, tell me if there are any more flags in HP-12C which could be used?

                        
Re: Capture the flag - HP-12C programming contest
Message #8 Posted by Gerson W. Barbosa on 11 Feb 2011, 9:45 p.m.,
in response to message #4 by gene wright

Quote:
1.022 ENTER 1 CHS DATE LSTx - x=0

Have I misunderstood something here? This returns 2.012 in M.DY mode and 32.012 in D.MY mode. That is, false for both modes.

1.012 ENTER 1 DATE INTG 1 - x=0 will return 0 and 1, respectively. Same number of steps though.

                              
Re: Capture the flag - HP-12C programming contest
Message #9 Posted by gene wright on 12 Feb 2011, 1:14 p.m.,
in response to message #8 by Gerson W. Barbosa

Oops. Shoudl have been:

1.022 ENTER 1 CHS DATE LSTx + x=0

                                    
Fewer steps
Message #10 Posted by gene wright on 13 Feb 2011, 5:36 p.m.,
in response to message #9 by gene wright

0 FV 1 STO n STO i STO PV PMT 1 + X=0?

                                          
Re: Fewer steps
Message #11 Posted by Allen on 13 Feb 2011, 6:59 p.m.,
in response to message #10 by gene wright

A very concise test! Well done, sir!


[ Return to Index | Top of Index ]

Go back to the main exhibit hall