The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
HHC 2016 RPL Programming Contest (HP-71B)
09-22-2016, 10:58 PM
Post: #1
HHC 2016 RPL Programming Contest (HP-71B)
Hi all:

Sorry to be so late but I just came back home from a 2-month unplugged summer vacation in the countryside and saw this HHC 2016 RPL challenge at the forum. I've completely refrained from reading the various threads so as not to spoil it for me and thus be able to give it a try in bare-bones HP-71B's BASIC (no ROMs or LEX files).

I quickly came to this 1-liner (6 statements, 50 bytes) solution:

1 INPUT S$ @ M=0 @ FOR I=1 TO LEN(S$) @ M=MAX(M,I-POS(S$,S$[I,I])) @ NEXT I @ DISP M

>RUN
? HIPPOPOTAMUS [ENTER]
3
...

>RUN
? pablitoclavounclavito [ENTER]
15


which delivers the goods, it's easy to understand and works for any input, including lowercase or any other characters, as well as single characters and the null string.

I don't know how this compares lengthwise to the best RPL solutions (as I said, I haven't read the RPL threads) but seems to me this is as simple as can be, except for the fact that I've also produced another 50-byte solution (same length) which uses no string variable (S$), just the numeric variables I (for the index) and M (to keep track of the maximum distance).

See if you can fathom how it's done (quite simple actually) ! 8-D

Regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HHC 2016 RPL Programming Contest (HP-71B) - Valentin Albillo - 09-22-2016 10:58 PM



User(s) browsing this thread: