RosettaCodeData/Task/Determine-if-a-string-is-collapsible/Applesoft-BASIC/determine-if-a-string-is-collapsible.basic
2024-10-16 18:07:41 -07:00

28 lines
740 B
Text

10 READ N
20 FOR A = 1 TO N
30 READ I$
40 GOSUB 100" COLLAPSE
50 PRINT LEN(I$) " <<<" I$ ">>>"
60 PRINT LEN(O$) " <<<" O$ ">>>"
70 PRINT
80 NEXT
90 END
REM COLLAPSE
100 O$ = I$
110 IF LEN(I$) < 2 THEN RETURN
120 O$ = ""
130 P$ = ""
140 FOR I = 1 TO LEN(i$)
150 C$ = MID$(I$,I,1)
160 IF C$ <> P$ THEN O$ = O$ + C$
170 P$ = C$
180 NEXT I
190 RETURN
400 DATA 5
410 DATA ""
420 DATA "'If I were two-faced, would I be wearing this one?' --- Abraham Lincoln "
430 DATA "..1111111111111111111111111111111111111111111111111111111111111117777888"
440 DATA "I never give 'em hell, I just tell the truth, and they think it's hell. "
450 DATA " --- Harry S Truman "