aboutsummaryrefslogtreecommitdiffstats
path: root/day5/part1.bas
blob: d9ee35183a2a0a9cc5db4f14ec701fb89db025bf (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
REM Advent of Code 2022: Day 5, part 1
REM Written in Applesoft BASIC

 10  DIM ST$(9)
 20  FOR I = 0 TO 8:ST$(I) = "": NEXT I
 30  ONERR  GOTO 900
 60  PRINT  CHR$ (4),"OPEN INPUT"
 70  PRINT  CHR$ (4),"READ INPUT"
 90 J = 1
 91 K = 0
 92 L = 0
 93  DIM AC(3):AC(0) = 0:AC(1) = 0:AC(2) = 0
 94 V = 0
 100  GET C$: GET D$
 110 CV =  ASC (C$)
 120  IF CV > 47 AND CV < 58 GOTO 300
 130  IF J > 0 THEN J = J - 1: GOTO 100
 140  IF CV <  > 32 THEN ST$(K) = C$ + ST$(K)
 150 J = 3
 160 K = K + 1
 170  IF K > 8 THEN K = 0
 180  GOTO 100
 300  FOR I = 0 TO 8
 310  PRINT ST$(I)
 320  NEXT I
 325  PRINT 
 330 CL = 0
 340  GET C$: GET Z$
 350  IF CL = 13 AND  ASC (C$) = 13 GOTO 400
 360 CL =  ASC (C$)
 370  GOTO 340
 400  GET C$: GET Z$
 410 CV =  ASC (C$)
 420  IF CV < 48 OR CV > 57 GOTO 400
 430 V = V * 10 + CV - 48
 440  GET C$: GET Z$
 445 CV =  ASC (C$)
 450  IF CV > 47 AND CV < 58 GOTO 430
 460 AC(L) = V
 465 V = 0
 470 L = L + 1
 480  IF L < 3 GOTO 400
 485 AC(0) = AC(0) - 1
 490 AC(1) = AC(1) - 1
 495 AC(2) = AC(2) - 1
 500  FOR I = 0 TO AC(0)
 510 ST$(AC(2)) = ST$(AC(2)) +  RIGHT$ (ST$(AC(1)),1)
 515  IF  LEN (ST$(AC(1))) = 1 THEN ST$(AC(1)) = "": GOTO 530
 520 ST$(AC(1)) =  LEFT$ (ST$(AC(1)), LEN (ST$(AC(1))) - 1)
 530  NEXT I
 600  FOR I = 0 TO 8
 610  PRINT ST$(I)
 620  NEXT I
 625  PRINT 
 630 L = 0
 640  GOTO 400
 900  PRINT  CHR$ (4),"CLOSE"
 910  END