RPL mini-challenge: Create an anti-Identity Matrix
05-12-2018, 05:48 PM (This post was last modified: 05-12-2018 09:50 PM by DavidM.)
Post: #1
 DavidM Senior Member Posts: 748 Joined: Dec 2013
RPL mini-challenge: Create an anti-Identity Matrix
Inspired by Ángel Martin's 41CL quiz, I am intrigued by the concept of the "anti-Identity" matrix. Not having a 41CL prevents me from participating in the quiz, but I thought I might experiment with an RPL version of the first part his challenge: creating the anti-Identity matrix.

John Keith came up with a very similar RPL program to my first attempt, which essentially creates the matrix by generating a matrix of 1s and subtracting its identity from it. This makes for a compact solution, but it strikes me that it's not very internally efficient. The result is good, of course, but the majority of computation to create it is unnecessary (there's lots of 1-0 going on to get the final matrix). This extra computation slows it down.

So here's the challenge:

Given an integer input in stack level 1 representing the dimension of the square matrix, create the anti-Identity form as quickly as possible (all 1s except for 0s on the diagonal).

Rules:
- To simplify the approach, you may assume that the input is a valid integer > 1.
- Standard User RPL commands only for HP 49G and later systems (no SysRPL, Saturn, SYSEVALs, or third-party commands).
- To make it more interesting on the 48-series systems, strategic SYSEVAL commands may be used if desired (provided they aren't used to simply execute an entire block of SysRPL or Saturn code).
- Winners will be based on execution time of an input of 30, but the program should work properly with other inputs as well.
- Execution time is defined as the time to complete the program on real hardware as opposed to an emulator.
- Assume approximate mode for both constants and calculations on systems that support exact integers (49G-49g+-50g-48gII).
 « Next Oldest | Next Newest »

 Messages In This Thread RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-12-2018 05:48 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Gerald H - 05-12-2018, 06:37 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-12-2018, 07:33 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Zaphod - 05-12-2018, 08:04 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - 3298 - 05-12-2018, 08:44 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Gerald H - 05-12-2018, 09:07 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - 3298 - 05-13-2018, 08:48 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-12-2018, 09:45 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-12-2018, 10:00 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-12-2018, 10:16 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-13-2018, 02:29 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-13-2018, 02:52 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Zaphod - 05-13-2018, 06:02 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-13-2018, 08:46 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-13-2018, 03:19 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Joe Horn - 05-13-2018, 06:00 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-13-2018, 08:52 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-13-2018, 03:11 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Gerald H - 05-13-2018, 06:52 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-13-2018, 08:54 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - grsbanks - 05-13-2018, 09:22 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-13-2018, 09:51 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-13-2018, 03:01 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-13-2018, 07:32 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-13-2018, 10:27 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-13-2018, 02:44 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Didier Lachieze - 05-13-2018, 03:40 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Joe Horn - 05-13-2018, 08:46 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-13-2018, 08:58 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-13-2018, 09:55 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-14-2018, 03:49 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-14-2018, 07:12 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-15-2018, 10:36 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-15-2018, 12:22 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - John Keith - 05-15-2018, 04:52 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-16-2018, 02:03 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Gerald H - 05-15-2018, 05:45 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-15-2018, 11:12 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - toml_12953 - 05-15-2018, 03:58 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-16-2018, 01:56 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Gerald H - 05-15-2018, 07:05 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - Gerald H - 05-15-2018, 01:57 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - David Hayden - 05-15-2018, 03:31 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - Claudio L. - 05-15-2018, 06:48 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - DavidM - 05-16-2018, 01:27 AM RE: RPL mini-challenge: Create an anti-Identity Matrix - John Keith - 05-15-2018, 08:30 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-15-2018, 06:59 PM RE: RPL mini-challenge: Create an anti-Identity Matrix - pier4r - 05-16-2018, 06:00 AM

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