' Determine if a string is collapsible DECLARE FUNCTION Collapse$ (StrIn$) READ N% FOR A% = 1 TO N% READ StrIn$ StrOut$ = Collapse$(StrIn$) PRINT LEN(StrIn$); "<<<"; StrIn$; ">>>" PRINT LEN(StrOut$); "<<<"; StrOut$; ">>>" PRINT NEXT END DATA 5: ' There are 5 strings DATA "" DATA "'If I were two-faced, would I be wearing this one?' --- Abraham Lincoln " DATA "..1111111111111111111111111111111111111111111111111111111111111117777888" DATA "I never give 'em hell, I just tell the truth, and they think it's hell. " DATA " --- Harry S Truman " FUNCTION Collapse$ (StrIn$) IF StrIn$ = "" THEN StrOut$ = StrIn$ ELSE StrOut$ = SPACE$(LEN(StrIn$)) P$ = LEFT$(StrIn$, 1) MID$(StrOut$, 1, 1) = P$ T% = 2 FOR I% = 2 TO LEN(StrIn$) C$ = MID$(StrIn$, I%, 1) IF P$ <> C$ THEN MID$(StrOut$, T%, 1) = C$ T% = T% + 1 P$ = C$ END IF NEXT StrOut$ = LEFT$(StrOut$, T% - 1) END IF Collapse$ = StrOut$ END FUNCTION