aboutsummaryrefslogtreecommitdiffstats
path: root/day6/part1.bas
blob: cb04c43c6e08ab13b9e8f3790ff2d70b19e19269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
REM Advent of Code 2022: Day 6, part 1
REM Written in Applesoft BASIC

 5  HOME 
 10 A = 1000
 20 R = 0
 50  PRINT  CHR$ (4),"OPEN INPUT"
 60  PRINT  CHR$ (4),"READ INPUT"
 70  ONERR  GOTO 900
 100  PRINT "INITIALIZING COMMUNICATION SYSTEM";
 105 A = 350
 110  FOR I = 0 TO 6
 120  GOSUB 1000
 130  PRINT ".";
 140  NEXT I
 150  PRINT 
 200  PRINT "OPENING SIGNAL DATASTREAM";
 210  FOR I = 0 TO 6
 220  GOSUB 1000
 230  PRINT ".";
 240  NEXT I
 250  PRINT 
 260  PRINT 
 300  PRINT "SCANNING FOR START-OF-PACKET MARKER:"
 310  HTAB 1
 320  VTAB 8
 330  PRINT "||||";
 340  HTAB 1
 350  VTAB 10
 360  PRINT "||||";
 400  HTAB 1
 410  VTAB 9
 420  PRINT S$;
 430  IF  LEN (S$) >  = 4 GOTO 500
 440  GET C$
 450 S$ = C$ + S$
 455  IF  LEN (S$) > 40 THEN S$ =  MID$ (S$,1,40)
 460 A = 80
 470  GOSUB 1000
 475 R = R + 1
 480  GOTO 400
 500  HTAB 1
 510  VTAB 7
 530  IF  MID$ (S$,1,1) =  MID$ (S$,2,1) THEN  PRINT "/\  ";: GOTO 600
 540  IF  MID$ (S$,1,1) =  MID$ (S$,3,1) THEN  PRINT "/-\ ";: GOTO 600
 550  IF  MID$ (S$,1,1) =  MID$ (S$,4,1) THEN  PRINT "/--\";: GOTO 600
 560  IF  MID$ (S$,2,1) =  MID$ (S$,3,1) THEN  PRINT " /\ ";: GOTO 600
 570  IF  MID$ (S$,2,1) =  MID$ (S$,4,1) THEN  PRINT " /-\";: GOTO 600
 580  IF  MID$ (S$,3,1) =  MID$ (S$,4,1) THEN  PRINT "  /\";: GOTO 600
 590  PRINT "    ";
 595  GOTO 700
 600  GOTO 440
 620  VTAB 14
 700  HTAB 1
 710  VTAB 13
 720  PRINT "MARKER FOUND AT INDEX ";R;"."
 900  PRINT  CHR$ (4),"CLOSE"
 910  END 
 1000  FOR Z = 0 TO A: NEXT Z
 1010  RETURN