Determine if a string is collapsible: Difference between revisions

Content deleted Content added
Petelomax (talk | contribs)
Added BaCon version.
Line 231:
new: 14 <<<headmistreship>>>
</pre>
 
=={{header|BaCon}}==
<lang qbasic>DECLARE str$ = "; \
\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln ; \
..1111111111111111111111111111111111111111111111111111111111111117777888; \
I never give 'em hell, I just tell the truth, and they think it's hell. ; \
--- Harry S Truman ; \
The better the 4-wheel drive, the further you'll be from help when ya get stuck!; \
headmistressship"
 
FOR x$ IN str$ STEP ";"
found = 0
PRINT "<<<", x$, ">>> - length: ", LEN(x$)
PRINT "<<<";
FOR y = 1 TO LEN(x$)
IF MID$(x$, y, 1) <> MID$(x$, y+1, 1) THEN
PRINT MID$(x$, y, 1);
INCR found
ENDIF
NEXT
PRINT ">>> - length: ", found
NEXT</lang>
{{out}}
<pre><<<>>> - length: 0
<<<>>> - length: 0
<<<"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln >>> - length: 72
<<<"If I were two-faced, would I be wearing this one?" - Abraham Lincoln >>> - length: 70
<<<..1111111111111111111111111111111111111111111111111111111111111117777888>>> - length: 72
<<<.178>>> - length: 4
<<<I never give 'em hell, I just tell the truth, and they think it's hell. >>> - length: 72
<<<I never give 'em hel, I just tel the truth, and they think it's hel. >>> - length: 69
<<< --- Harry S Truman >>> - length: 72
<<< - Hary S Truman >>> - length: 17
<<<The better the 4-wheel drive, the further you'll be from help when ya get stuck!>>> - length: 80
<<<The beter the 4-whel drive, the further you'l be from help when ya get stuck!>>> - length: 77
<<<headmistressship>>> - length: 16
<<<headmistreship>>> - length: 14</pre>
 
=={{header|C}}==