HP Forums
RPL Micro-Challenge: Christmas in July - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: RPL Micro-Challenge: Christmas in July (/thread-8692.html)

Pages: 1 2


RE: RPL Micro-Challenge: Christmas in July - Gerson W. Barbosa - 07-19-2017 02:07 PM

(07-19-2017 01:42 PM)Dave Britten Wrote:  Oh, duh, I was doing COMB(x+2, x-1), completely forgetting about the symmetric nature of combinations.

I did that as well.

(x+2)!(x-1)!/6. (37.5 bytes)

COMB(x+2, x-1) (27.5 bytes)

COMB(x+2, 3) (20 bytes)

PS: Next, this "masterpiece" :-)

« DUP 2. + IDN →DIAG PCOEF SWAP GET ABS
» (38.5 bytes)


RE: RPL Micro-Challenge: Christmas in July - rprosperi - 07-19-2017 03:24 PM

(07-19-2017 12:56 PM)Joe Horn Wrote:  This is an example of program optimization being obtained not by code optimization but by math optimization.

Clever, and good eye to recognize the pattern, which I did not. Though, I have become re-acquainted with the AUR as a result of this challenge.

I was looking for some form of the PI (Product) function, since this is also PI, for i, 0 to 2 of (x + i) / (1 + i), though even if I found it, the formula still needed more bytes than 20.

Still, educational and fun, so thanks for that Joe.

For those interested, John Meyer wrote-up a very interesting PI solution, here.


RE: RPL Micro-Challenge: Christmas in July - Gerald H - 07-19-2017 03:28 PM

If you're interested in the series much info here:

https://oeis.org/A000292


RE: RPL Micro-Challenge: Christmas in July - Claudio L. - 07-19-2017 03:51 PM

(07-19-2017 02:07 PM)Gerson W. Barbosa Wrote:  PS: Next, this "masterpiece" :-)

« DUP 2. + IDN →DIAG PCOEF SWAP GET ABS
» (38.5 bytes)

This is what I had:

Code:

« [ 1 3 2 0 ] SWAP PEVAL 6. / »
and another variant:
Code:

« { 0 1 2 } ADD ΠLIST 6. / »

Needs to be compiled in exact mode (no dot in the integer vector) and you get 38 bytes and 38.5 bytes respectively.


RE: RPL Micro-Challenge: Christmas in July - Gerson W. Barbosa - 07-19-2017 04:14 PM

82 bytes and counting :-)

« → n
« '∑(j=1,n,∑(k=1,j,k))' EVAL
»
»


RE: RPL Micro-Challenge: Christmas in July - Gerson W. Barbosa - 07-19-2017 04:37 PM

(07-19-2017 12:56 PM)Joe Horn Wrote:  EDIT: I just noticed something cool. If you run the program above on an input of 'X' (undefined), and then EVAL the resulting mess, you get this:

\[\frac { { X }^{ 3 }+3{ X }^{ 2 }+2X }{ 6 }\]
Now press FACTOR (or COLLECT) and see this:
\[\frac { X\cdot (X+1)\cdot (X+2) }{ 3\cdot 2 }\]
It almost does all the thinking for you. Big Grin

It works with most programs:

X « 1 + DUP ACOSH SINH SQ * 6 / » EVAL LIN FACTOR --> 'X*(X+1)*(X+2)/(3*2)'



RE: RPL Micro-Challenge: Christmas in July - Gilles59 - 07-19-2017 06:22 PM

(07-19-2017 04:14 PM)Gerson W. Barbosa Wrote:  
Code:
 ∑(j=1,n,∑(k=1,j,k))

It was what I did in the equation writer to find the expression.
After evalution, just do FACTOR ;D