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 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
HHC 2016 RPL Programming Contest (HP-71B) - Valentin Albillo - 09-22-2016 10:58 PM
RE: HHC 2016 RPL Programming Contest (HP-71B) - J-F Garnier - 09-25-2016, 08:11 AM
RE: HHC 2016 RPL Programming Contest (HP-71B) - Valentin Albillo - 09-26-2016, 11:04 AM
|
User(s) browsing this thread: