[VA] Short & Sweet Math Challenge #25 "San Valentin's Special: Weird Math"
|
02-23-2021, 05:37 PM
(This post was last modified: 02-23-2021 05:43 PM by Gerson W. Barbosa.)
Post: #26
|
|||
|
|||
RE: [VA] Short & Sweet Math Challenge #25 "San Valentin's Special: Weird Math...
#6
Longer, but faster: 17.547 seconds on the HP 50g (previously 29.952 seconds for argument = 5000) « DUPDUP 4 * SWAP LN SQ / 3 XROOT 3 * CEIL { } 1 DUP2 ROT 5 ROLL START NEXTPRIME + LASTARG NIP NEXT DROP SQ DUP SIZE 2 SWAP FOR i 1 OVER SIZE 1 + i - FOR j DUP j DUP i + 1 - SUB ∑LIST 4 PICK OVER ≥ { ROT + SWAP } { DROP } IFTE NEXT NEXT + SORT REVLIST WHILE DUP HEAD PICK3 > REPEAT TAIL END REVLIST NIP » Checksum: # 5E22h Bytes: 238.5 bytes This is closer to the HP-75C version, except for the prime list: « DUPDUP 4 * SWAP LN SQ / 3 XROOT 3 * CEIL { } 1 DUP2 ROT 5 ROLL START NEXTPRIME + LASTARG NIP NEXT DROP SQ DUP SIZE 1 SWAP FOR i 1 OVER SIZE 1 + i - FOR j DUP j DUP i + 1 - SUB DUP SIZE 1 - NOT { 0 + } IFT ∑LIST 4 PICK OVER ≥ { ROT + SWAP } { DROP } IFTE NEXT NEXT ROT DROP2 SORT » Checksum: # A346h Bytes: 226.5 bytes 21.510 seconds As a comparison, the BASIC program takes about 96 seconds on the HP-75C. Also, the BASIC program is limited to arguments up to 5492, unless of course the prime list is extended. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)