Post Reply 
RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
07-02-2019, 12:07 AM (This post was last modified: 07-02-2019 12:14 AM by Gerson W. Barbosa.)
Post: #16
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
(07-01-2019 11:13 PM)Didier Lachieze Wrote:  
(07-01-2019 04:49 AM)Gerson W. Barbosa Wrote:  wp34s version:

001 LBL A
002 INC X
003 # 001
004 # 000
005 STO T
006 X<>Y
007 NEXTP
008 X<>Y
009 DSE X
010 BACK 004
011 x<> T
012 INC X
013 INC X
014 X<>Y
015 PSE 10
016 X<>Y
017 DSE Z
018 BACK 013
019 X<>Y
020 END

Your algorithm is great! Here is a slightly optimized version of the program (24 bytes), removing the unnecessary X<>Y instructions :

001 LBL A
002 c#001
003 <>XYZY
004 NEXTP
005 DSE T
006 BACK 002
007 INC Y
008 INC Y
009 PSE 10
010 DSL Z
011 BACK 008
012 END


EDIT: further optimized by removing the initial INC X with the usage of DSL in step 11.

A slightly optimized version? I wonder what your heavily optimized one would look like! :-)

Very nice! Indeed a masterpiece.

Yes, I noticed there were too many X<>Y instructions. “Let me remove a few and it’ll be perfect”, I thought.
Thank you very much for removing THEM ALL! :-)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g) - Gerson W. Barbosa - 07-02-2019 12:07 AM



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