Determine if a string is collapsible: Difference between revisions
Content deleted Content added
Added Quackery. |
|||
Line 2,257: | Line 2,257: | ||
length= 17 output=««« - Hary S Truman »»» |
length= 17 output=««« - Hary S Truman »»» |
||
═════════════════════════════════════════════════════════════════════════════════════════════════════════ |
═════════════════════════════════════════════════════════════════════════════════════════════════════════ |
||
</pre> |
|||
=={{header|Ring}}== |
|||
<lang ring> |
|||
load "stdlib.ring" |
|||
see "working..." + nl + nl |
|||
str = ["The better the 4-wheel drive, the further you'll be from help when ya get stuck!", |
|||
"I never give 'em hell, I just tell the truth, and they think it's hell.", |
|||
"..1111111111111111111111111111111111111111111111111111111111111117777888"] |
|||
strsave = str |
|||
for n = 1 to len(str) |
|||
for m = 1 to len(str[n])-1 |
|||
if substr(str[n],m,1) = substr(str[n],m+1,1) |
|||
str[n] = left(str[n],m) + right(str[n],len(str[n])-m-1) |
|||
for p = len(str[n]) to 2 step -1 |
|||
if substr(str[n],p,1) = substr(str[n],p-1,1) |
|||
str[n] = left(str[n],p-1) + right(str[n],len(str[n])-p) |
|||
ok |
|||
next |
|||
ok |
|||
next |
|||
next |
|||
for n = 1 to len(str) |
|||
see "" + len(strsave[n]) + "«««" + strsave[n] + "»»»" + nl |
|||
see "" + len(str[n]) + "«««" + str[n] + "»»»" + nl + nl |
|||
next |
|||
see "done..." + nl |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
working... |
|||
80«««The better the 4-wheel drive, the further you'll be from help when ya get stuck!»»» |
|||
77«««The beter the 4-whel drive, the further you'l be from help when ya get stuck!»»» |
|||
71«««I never give 'em hell, I just tell the truth, and they think it's hell.»»» |
|||
68«««I never give 'em hel, I just tel the truth, and they think it's hel.»»» |
|||
72«««..1111111111111111111111111111111111111111111111111111111111111117777888»»» |
|||
4«««.178»»» |
|||
done... |
|||
</pre> |
</pre> |
||