Longest string challenge: Difference between revisions

added RPL
(Adding Quackery.)
(added RPL)
Line 2,384:
ddd
ggg
</pre>
 
=={{header|RPL}}==
This program complies with the list of restrictions:
The main hack is based on the fact that the <code>SUB</code> function, which extracts one or more characters from a string, returns the null character if its arguments exceed the size of the string. A minor hack is to use <code>INCR</code> and <code>DECR</code> commands, instead of forbidden arithmetic operations.
The user stack is both the standard input and output.
{{works with|HP|49}}
≪ 1 → count
≪ 1 CF <span style="color:grey">@ flag 1 set means there are at least 2 strings in the stack</span>
'''WHILE''' "String?" "" INPUT DUP SIZE '''REPEAT'''
'''IF''' 1 FS? '''THEN'''
'''CASE'''
DUP2 SWAP SIZE DUP SUB NUM NOT '''THEN''' DROP '''END'''
DUP2 SIZE DUP SUB NUM NOT '''THEN''' 'count' INCR ROLLD 'count' DECR DROPN 1 'count' STO '''END'''
'count' INCR DROP
'''END'''
'''ELSE''' 1 SF '''END'''
'''END''' DROP
≫ ≫ '<span style="color:blue">TASK</span>' STO
 
<span style="color:blue">TASK</span>
"a" "bb" "ccc" "ddd" "ee" "f" "ggg" ""
{{out}}
<pre>
3: "ccc"
2: "ddd"
1: "ggg"
</pre>
 
1,151

edits