Post Reply 
RPL Micro-Challenge: Christmas in July
07-19-2017, 02:07 PM (This post was last modified: 07-19-2017 02:12 PM by Gerson W. Barbosa.)
Post: #21
RE: RPL Micro-Challenge: Christmas in July
(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)
Find all posts by this user
Quote this message in a reply
07-19-2017, 03:24 PM
Post: #22
RE: RPL Micro-Challenge: Christmas in July
(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.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-19-2017, 03:28 PM
Post: #23
RE: RPL Micro-Challenge: Christmas in July
If you're interested in the series much info here:

https://oeis.org/A000292
Find all posts by this user
Quote this message in a reply
07-19-2017, 03:51 PM
Post: #24
RE: RPL Micro-Challenge: Christmas in July
(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.
Find all posts by this user
Quote this message in a reply
07-19-2017, 04:14 PM
Post: #25
RE: RPL Micro-Challenge: Christmas in July
82 bytes and counting :-)

« → n
« '∑(j=1,n,∑(k=1,j,k))' EVAL
»
»
Find all posts by this user
Quote this message in a reply
07-19-2017, 04:37 PM (This post was last modified: 07-19-2017 04:42 PM by Gerson W. Barbosa.)
Post: #26
RE: RPL Micro-Challenge: Christmas in July
(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)'
Find all posts by this user
Quote this message in a reply
07-19-2017, 06:22 PM (This post was last modified: 07-19-2017 06:25 PM by Gilles59.)
Post: #27
RE: RPL Micro-Challenge: Christmas in July
(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
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)