Post Reply 
HHC 2016 RPL Programming Contest
09-18-2016, 11:55 PM
Post: #9
RE: HHC 2016 RPL Programming Contest
I decided to use this contest as yet another excuse to try out some list processing features. May not have been the best approach, but at least it forced me to experiment some more!

I assumed that a string with a single character was valid input and had to be handled with 0 as the result. This added 10 bytes to the final code.

This version has been tested with a Rev. R 48gx and Rev. 2.15 50g, and weighs in at 166 bytes:
Code:
%%HP: T(3)A(R)F(.);
\<<
  @ Explode string into char list
  1 OVER SIZE
  FOR n
    DUP n DUP SUB
    SWAP
  NEXT
  DROP
  DEPTH \->LIST

  @ Build First Char Pos/Last Char Pos lists
  1 2 START
    DUP 1 OVER
    \->STR "«" SWAP + "SWAP POS»" +
    OBJ\->
    DOLIST
    SWAP REVLIST
  NEXT

  @ Compute "difference" list
  SIZE 1 + SWAP - REVLIST
  SWAP -

  @ Find greatest value from difference list
  {0} +  @ Just in case there was only one char in string
  \<< MAX \>> STREAM

\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HHC 2016 RPL Programming Contest - Gene - 09-17-2016, 01:39 PM
RE: HHC 2016 RPL Programming Contest - DavidM - 09-18-2016 11:55 PM



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