Post Reply 
Mini-challenge: MAX(factors of 2 or 5)
01-19-2018, 10:38 PM
Post: #14
RE: Mini-challenge: MAX(factors of 2 or 5)
While I can appreciate your desire for a less brutish approach, Joe, I think it's going to be difficult to outperform your original method with standard RPL. FACTORS admittedly does more than is needed, but its speed makes it an attractive command to utilize here.

Just for something different, here's an alternative approach that still uses FACTORS, and what it lacks in elegance is more than made up for in obfuscation Smile:

Code:
\<<
  DUP
  {
    30 *
    FACTORS
    REVLIST
    1 5 SUB LIST\-> ROLLD
    DROP2 DROP
    MAX 1 -
  }
  IFT
\>>

Slightly slower than your original method, and still just parses the FACTORS list to get the needed values. It is a bit smaller, though. Could be even shorter if 0 doesn't need to be considered for input.

Personally, I don't see anything wrong with your initial approach. It is much clearer than the above monster, and that (to me) is far more valuable than the few bytes saved.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Mini-challenge: MAX(factors of 2 or 5) - DavidM - 01-19-2018 10:38 PM



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