The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

HCC2007 programming contest on 17bii
Message #1 Posted by Don Shepherd on 21 Nov 2007, 5:34 p.m.

OK, I know the HCC2007 programming contest was for the new 35C, but I couldn't resist trying it on the 17bii and 17bii+ solvers. The timings for the 4 numbers (9971892227, 7654321, 1234567891, and 1234554321) were: 25 seconds on the 17bii, and 54 seconds on the 17bii+ (newer isn't always better!).

The code is here. I first scanned the input number and incremented variables A-I with the number of 1's through 9's, then I went through the 9 variables and constructed the output number.

The code works on both the 17bii and 17bii+.

      
Re: HCC2007 programming contest on 17bii
Message #2 Posted by Andrés C. Rodríguez on 22 Nov 2007, 4:25 a.m.,
in response to message #1 by Don Shepherd

Now, this is challenging!!

Very interesting. The expression "hats off" comes to my mind, as a congratulation. If, for any idiomatic twist, it is not appropriate, please disregard.

            
Re: HCC2007 programming contest on 17bii
Message #3 Posted by Don Shepherd on 22 Nov 2007, 4:40 a.m.,
in response to message #2 by Andrés C. Rodríguez

Thank you, Andres. I liked your solution for the 35s also. I submitted an entry at HCC in San Diego, but I'm afraid I was not in the same league as the winner (I think my timing was about 58 seconds for the 4 numbers) :(

I really admire HP for creating products like the 35s and the 17bii. And especially since products like the 17bii allow you to program devices that generally are not considered programmable.

                  
Re: HCC2007 programming contest on 17bii
Message #4 Posted by Chris Dean on 22 Nov 2007, 5:55 p.m.,
in response to message #3 by Don Shepherd

Could we know what the contest actually was at HCC2007?

I have a HP17BII+ and a HP35S and I must admit I prefer programming the HP17BII+ as the code produced seems more meaningful with the ability to use proper variable names.

Is there a name for the programming language used on the HP17BII+? It is neither RPN or RPL and very simple with Let, Get, Sum and IF which are the basic tools for a programming language. It would be nice to be able to use subroutines i.e. to be able to use sine and cosine equations as subroutines. This does however make it a good challenging language to use.

I have the first style HP17BII+ with the small input key. I think the style, weight, shape and overall quality of the calculator is great. It also feels very tactile with the rubberised sides.

Edited: 22 Nov 2007, 5:58 p.m.

                        
Re: HCC2007 programming contest on 17bii
Message #5 Posted by Andrés C. Rodríguez (Argentina) on 22 Nov 2007, 6:51 p.m.,
in response to message #4 by Chris Dean

You may like to visit the following thread:

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/forum.cgi?read=128665#128665

Or read the final HHC 2007 report at:

http://www.holyjoe.net/hhc2007/Final_HHC2007_Conference_Report_R2.pdf

where a complete discussion about the contest could be found.

Enjoy, and let us have your views!!

                        
Re: HCC2007 programming contest on 17bii
Message #6 Posted by Don Shepherd on 22 Nov 2007, 6:55 p.m.,
in response to message #4 by Chris Dean

Chris, it's just called the Solver. It was designed to solve equations, but with the ability to loop and use variables, it qualifies as programming, IMHO.

                              
Re: HCC2007 programming contest on 17bii
Message #7 Posted by Chris Dean on 22 Nov 2007, 7:24 p.m.,
in response to message #6 by Don Shepherd

Thanks for the feedback. I have saved the HCC 2007 report to read. By the way Don I thought your solution to the problem looked good.

                                    
Re: HCC2007 programming contest on 17bii
Message #8 Posted by Don Shepherd on 22 Nov 2007, 7:38 p.m.,
in response to message #7 by Chris Dean

Thanks Chris. It was fun to do. It made me wish for indirect addressing, however!

      
Re: HCC2007 programming contest on 17bii
Message #9 Posted by Bill (Smithville, NJ) on 22 Nov 2007, 10:39 p.m.,
in response to message #1 by Don Shepherd

Hi Don,

Thanks for posting your code. Don and I have been bouncing the solver versions back and forth for the past few weeks. His version is the fastest. To give a couple of other variations, the following are two of my slower versions:

Selection Sort- 10 Second time (to reverse one 10 digit number) on HP-19BII:

R= 0 * L(K:X) + 
   0 * L(Y,LOG(X)) +
   0 * SIGMA(N1:1:G(Y):1:
       L(D1:IP(10*FP(G(K)/10^N1))) + 
       L(MAX:G(D1)) + 
       L(N3:0) +
       0 * SIGMA(N2:N1+1:G(Y)+1:1:
           L(D2:IP(10*FP(G(K)/10^N2))) +
           IF (G(D2) > G(MAX): 
               L(MAX:G(D2)) + 
               L(N3:N2):0)
           ) +
       IF (G(N3) > 0:
          L(K:G(K)-(G(D1)*10^(N1-1))
                  +(G(MAX)*10^(N1-1))
                  -(G(MAX)*10^(G(N3)-1))
                  +(G(D1)*10^(G(N3)-1)))
         :0)
        )
        + L(R:G(K))

Another version was to scan for largest digit and build up new number in separate variable. Unfortunately, it's 14 seconds to reverse one 10 digit number:

R= 0 * L(P:0) +
   0 * L(K:X) +
   0 * L(Y,LOG(X)+1) +
   0 * SIGMA(N1:1:G(Y):1:
       L(MAX:0) +
       0 * SIGMA(N2:1:G(Y):1:
           L(D1:IP(10*FP(G(K)/10^N2))) +
           IF(G(D1)>G(MAX):
              L(MAX:G(D1)) +
              L(N3:N2):0)
            ) +
       L(P:G(P)+G(MAX)*10^(N1-1)) +
       L(K:G(K)-G(MAX)*10^(G(N3)-1))
     ) +
     L(R:G(P))

It's interesting that the nested IF's in Don's version is a lot faster than straight swapping of variables. A lot has to do with the total number of steps that each pass takes.

I want to thank Don for getting me interested in this problem. It was a lot of fun to try to tweak the code. I'm sure there are more variations that can be done with it.

Bill

Edited: 22 Nov 2007, 10:59 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall