Post Reply 
RPL mini-challenge: Create an anti-Identity Matrix
05-13-2018, 02:44 PM
Post: #21
RE: RPL mini-challenge: Create an anti-Identity Matrix
(05-13-2018 06:00 AM)Joe Horn Wrote:  How about this:
<< IDN << NOT >> MAP >>

Nice, Joe! I'd be surprised if a more concise version exists (this one is 33 bytes). This is actually a great example of how size and speed don't always go hand-in-hand, though. In this case, IDN is quite fast, but applying NOT with MAP slows it down considerably. But I definitely think this qualifies as elegant.

(05-13-2018 06:52 AM)Gerald H Wrote:  Slightly faster than my 1st effort:

Code:
« DUP 1. →LIST 1 CON 1. PICK3
  FOR i DUP i 0 PUT UNROT
  NEXT DROP ROW→
»

Nice refinements, Gerald! My 50g clocked in at 1.21s for this one, which I believe is the fastest I've seen yet for an output of exact integers.

(05-13-2018 10:27 AM)pier4r Wrote:  ...Fixed values, but not difficult to modify with variables.
Code:

@ Idea: create N-1 rows of the form 0 1 1 .. 1 with as many 1 as N
@ add an ending 0
@ compact it in a matrix
@0.18 seconds
\<< 1. 29.
  START 
    0. 1. 30. NDUPN DROP
  NEXT 
  0. 
  30. DUP 2. \->LIST \->ARRY
\>>

You're definitely getting great performance here, Pier! I look forward to seeing how this does once you've altered it to accept the dimension as an input variable.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-13-2018 02:44 PM



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