Post Reply 
MC: Faster User-RPL HILBERT
07-09-2018, 05:25 PM
Post: #5
RE: MC: Faster User-RPL HILBERT
(07-09-2018 03:16 PM)Thomas Okken Wrote:  I'm guessing the point of the exercise is to avoid unnecessary calculations.

Exactly.

(07-09-2018 03:16 PM)Thomas Okken Wrote:  This will do so, at the cost of putting n^2 objects on the stack:

Code:
<< DUP 1 - -> n n1
   << 1 n FOR i i INV NEXT
      n 1 + n n1 + FOR i n1 DUPN i INV NEXT
      n DUP 2 ->LIST ->ARRY
   >>
>>

119.5 bytes.

I like your idea of pre-calculating n-1 and storing it in a local variable (n1) rather than doing "n 1 -" over and over inside the loop (which is what I did). Your program is therefore faster than mine: 50×50 in 0.71 seconds instead of my 0.8 seconds on an HP 50g in approx mode. And I was surprised that your "n DUP 2 ->LIST ->ARRY" is shorter than my "{ n n } ->ARRY". Very cool! Smile

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
MC: Faster User-RPL HILBERT - Joe Horn - 07-09-2018, 01:28 PM
RE: MC: Faster User-RPL HILBERT - Joe Horn - 07-09-2018 05:25 PM
RE: MC: Faster User-RPL HILBERT - Joe Horn - 07-09-2018, 11:43 PM
RE: MC: Faster User-RPL HILBERT - Gerald H - 07-10-2018, 09:50 AM
RE: MC: Faster User-RPL HILBERT - ttw - 07-09-2018, 05:10 PM
RE: MC: Faster User-RPL HILBERT - Werner - 07-10-2018, 07:20 AM
RE: MC: Faster User-RPL HILBERT - Juan14 - 08-05-2018, 06:31 PM



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