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. *