day6: basic for both parts

master
Clyne 2 years ago
parent 9be1e181be
commit 63cb27c091

@ -1,4 +1,4 @@
REM Advent of Code 2022: Day 6, part 1
REM Advent of Code 2022: Day 6, part 1 and 2
REM Written in Applesoft BASIC
5 HOME
@ -53,9 +53,58 @@ REM Written in Applesoft BASIC
620 VTAB 14
700 HTAB 1
710 VTAB 13
715 A = 1300
720 PRINT "MARKER FOUND AT INDEX ";R;"."
725 GOSUB 1000
730 PRINT
740 PRINT "ENGAGING FULL-SPEED SEARCH FOR START-OF-MESSAGE MARKER:"
750 GOSUB 1000
760 GOTO 2000
900 PRINT CHR$ (4),"CLOSE"
910 END
1000 FOR Z = 0 TO A: NEXT Z
1010 RETURN
2000 HTAB 1
2010 VTAB 19
2020 PRINT "||||||||||||||";
2030 HTAB 1
2040 VTAB 21
2050 PRINT "||||||||||||||";
2060 PRINT CHR$ (4),"CLOSE"
2070 PRINT CHR$ (4),"OPEN INPUT"
2080 PRINT CHR$ (4),"READ INPUT"
2090 S$ = "":R = 0
2095 M = 0
2100 HTAB 1
2110 VTAB 20
2120 PRINT S$;
2130 GET C$
2140 S$ = C$ + S$
2145 R = R + 1
2150 IF LEN (S$) < 14 GOTO 2100
2160 IF LEN (S$) > 40 THEN S$ = MID$ (S$,1,40)
2170 IF M > 0 THEN M = M - 1: GOTO 2100
2190 I = 1
2200 M = 0
2210 FOR J = I + 1 TO 14
2220 IF MID$ (S$,I,1) = MID$ (S$,J,1) THEN M = J:J = 14
2230 NEXT J
2240 IF M < > 0 GOTO 2300
2250 I = I + 1
2260 IF I < 14 GOTO 2200
2270 GOTO 2400
2300 HTAB I
2310 VTAB 18
2314 PRINT " ";
2318 HTAB I
2320 FOR J = I TO M
2330 PRINT "-";
2340 NEXT J
2345 M = 14 - M
2350 GOTO 2100
2400 HTAB 1
2410 VTAB 23
2420 PRINT "MESSAGE FOUND AT INDEX ";R"."
2425 GOSUB 1000
2430 GOTO 900
Loading…
Cancel
Save