HP Forums

Full Version: RPL Micro-Challenge: Christmas in July
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(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)
(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.
If you're interested in the series much info here:

https://oeis.org/A000292
(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.
82 bytes and counting :-)

« → n
« '∑(j=1,n,∑(k=1,j,k))' EVAL
»
»
(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)'
(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
Pages: 1 2
Reference URL's