aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-12-04 19:34:59 -0500
committerClyne Sullivan <clyne@bitgloo.com>2022-12-04 19:34:59 -0500
commitad6eddeeb7ec5145d3cf38ecd21dfb1f71fd4bf2 (patch)
tree2602af0889339037a23a7e052ee0e499852167b1
parent23effc48309276caead656b366a8bd915196fef5 (diff)
days 2 and 4 in apple basic
-rw-r--r--day2/part1.bas25
-rw-r--r--day2/part2.bas24
-rw-r--r--day4/part1.bas28
-rw-r--r--day4/part2.bas27
4 files changed, 104 insertions, 0 deletions
diff --git a/day2/part1.bas b/day2/part1.bas
new file mode 100644
index 0000000..c2a1b8d
--- /dev/null
+++ b/day2/part1.bas
@@ -0,0 +1,25 @@
+REM Advent of Code 2022: Day 2, part 1
+REM Written in Applesoft BASIC
+
+ 10 ONERR GOTO 900
+ 20 PRINT CHR$ (4),"OPEN INPUT"
+ 30 PRINT CHR$ (4),"READ INPUT"
+ 60 DIM RPC$(3):RPC$(0) = "ROCK":RPC$(1) = "PAPER":RPC$(2) = "SCISSORS"
+ 70 SC = 0
+ 100 GET A$: GET Z$
+ 110 GET Z$: GET Z$
+ 120 GET B$: GET Z$
+ 130 GET Z$: GET Z$
+ 140 AV = ASC (A$) - 65
+ 150 BV = ASC (B$) - 88
+ 200 SC = SC + BV + 1
+ 230 R = AV - BV
+ 240 IF AV = BV THEN SC = SC + 3: GOTO 300
+ 250 IF AV = 0 AND BV = 1 THEN SC = SC + 6: GOTO 300
+ 260 IF AV = 1 AND BV = 2 THEN SC = SC + 6: GOTO 300
+ 270 IF AV = 2 AND BV = 0 THEN SC = SC + 6
+ 300 PRINT RPC$(AV),"VS.",RPC$(BV),"SCORE = ";SC
+ 310 GOTO 100
+ 900 PRINT CHR$ (4),"CLOSE"
+ 910 END
+
diff --git a/day2/part2.bas b/day2/part2.bas
new file mode 100644
index 0000000..9f8b768
--- /dev/null
+++ b/day2/part2.bas
@@ -0,0 +1,24 @@
+REM Advent of Code 2022: Day 2, part 2
+REM Written in Applesoft BASIC
+
+ 10 ONERR GOTO 900
+ 20 PRINT CHR$ (4),"OPEN INPUT"
+ 30 PRINT CHR$ (4),"READ INPUT"
+ 60 DIM RPC$(3):RPC$(0) = "ROCK":RPC$(1) = "PAPER":RPC$(2) = "SCISSORS"
+ 70 SC = 0
+ 80 DIM OC(9):OC(0) = 3:OC(1) = 4:OC(2) = 8:OC(3) = 1:OC(4) = 5:OC(5) = 9:OC(6) = 2:OC(7) = 6:OC(8) = 7
+ 90 DIM MYC$(3):MYC$(0) = "LOSE":MYC$(1) = "DRAW":MYC$(2) = "WIN"
+ 100 GET A$: GET Z$
+ 110 GET Z$: GET Z$
+ 120 GET B$: GET Z$
+ 130 GET Z$: GET Z$
+ 140 AV = ASC (A$) - 65
+ 150 BV = ASC (B$) - 88
+ 160 OI = AV * 3 + BV
+ 170 SC = SC + OC(OI)
+ 180 PRINT "OPPONENT PLAYS ";RPC$(AV);",","I ";MYC$(BV);".","SCORE = ";SC
+ 190 GOTO 100
+ 900 PRINT CHR$ (4),"CLOSE"
+ 910 END
+
+
diff --git a/day4/part1.bas b/day4/part1.bas
new file mode 100644
index 0000000..120b050
--- /dev/null
+++ b/day4/part1.bas
@@ -0,0 +1,28 @@
+REM Advent of Code 2022: Day 4, part 1
+REM Written in Applesoft BASIC
+
+ 10 ONERR GOTO 900
+ 20 PRINT CHR$ (4),"OPEN INPUT"
+ 30 PRINT CHR$ (4),"READ INPUT"
+ 40 DIM GP(4)
+ 50 DU = 0
+ 100 FOR I = 0 TO 3:GP(I) = 0: NEXT I
+ 110 I = 0
+ 200 GET C$: GET Z$
+ 210 CV = ASC (C$)
+ 220 IF CV < 48 GOTO 300
+ 230 IF CV > 57 GOTO 300
+ 240 CV = CV - 48
+ 250 GP(I) = GP(I) * 10 + CV
+ 260 GOTO 200
+ 300 I = I + 1
+ 310 IF I < 4 GOTO 200
+ 400 IF GP(0) > = GP(2) AND GP(1) < = GP(3) GOTO 500
+ 410 IF GP(2) > = GP(0) AND GP(3) < = GP(1) GOTO 500
+ 430 GOTO 100
+ 500 DU = DU + 1
+ 510 PRINT "EXTRA CLEANING DONE BY ";DU;" ELVES..."
+ 520 GOTO 100
+ 900 PRINT CHR$ (4),"CLOSE"
+ 910 END
+
diff --git a/day4/part2.bas b/day4/part2.bas
new file mode 100644
index 0000000..1c53d60
--- /dev/null
+++ b/day4/part2.bas
@@ -0,0 +1,27 @@
+REM Advent of Code 2022: Day 4, part 2
+REM Written in Applesoft BASIC
+
+ 10 ONERR GOTO 900
+ 20 PRINT CHR$ (4),"OPEN INPUT"
+ 30 PRINT CHR$ (4),"READ INPUT"
+ 40 DIM GP(4)
+ 50 DU = 0
+ 100 FOR I = 0 TO 3:GP(I) = 0: NEXT I
+ 110 I = 0
+ 200 GET C$: GET Z$
+ 210 CV = ASC (C$)
+ 220 IF CV < 48 GOTO 300
+ 230 IF CV > 57 GOTO 300
+ 240 CV = CV - 48
+ 250 GP(I) = GP(I) * 10 + CV
+ 260 GOTO 200
+ 300 I = I + 1
+ 310 IF I < 4 GOTO 200
+ 400 IF GP(3) > = GP(0) AND GP(1) > = GP(2) GOTO 500
+ 430 GOTO 100
+ 500 DU = DU + 1
+ 510 PRINT "EXTRA CLEANING DONE BY ";DU;" ELVES..."
+ 520 GOTO 100
+ 900 PRINT CHR$ (4),"CLOSE"
+ 910 END
+