aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-12-01 07:59:42 -0500
committerClyne Sullivan <clyne@bitgloo.com>2022-12-01 07:59:42 -0500
commitd1df588459c25bf68122fb703914abafbe3bb27f (patch)
tree73a943a30f7878345441da8789db73ad4fdbb207
parent8d43e37df99f280377bed90284d6ac2428334804 (diff)
add day 1
-rw-r--r--day1/README.md10
-rw-r--r--day1/part1.bas25
-rw-r--r--day1/part2.bas30
-rwxr-xr-xday1/proof.jpgbin0 -> 108545 bytes
4 files changed, 65 insertions, 0 deletions
diff --git a/day1/README.md b/day1/README.md
new file mode 100644
index 0000000..5d3243d
--- /dev/null
+++ b/day1/README.md
@@ -0,0 +1,10 @@
+These challenges were completed on an Apple \]\[ GS using Applesoft BASIC.
+
+This required connecting the Apple to a modern computer over serial to receive the input data and upload the final source code. Communications ran at 19200 baud. More setup details will be added in the future.
+
+Each part takes about a minute and a half to execute.
+
+Here's a picture of the results of part2.bas on the Apple:
+
+![](https://raw.githubusercontent.com/tcsullivan/advent-of-code/master/day1/proof.jpg)
+
diff --git a/day1/part1.bas b/day1/part1.bas
new file mode 100644
index 0000000..353eea5
--- /dev/null
+++ b/day1/part1.bas
@@ -0,0 +1,25 @@
+REM Advent of Code 2022: Day 1, part 1
+REM Written in Applesoft BASIC
+
+ 10 ONERR GOTO 900
+ 20 MOST = 0:CURR = 0
+ 30 PRINT CHR$ (4),"OPEN INPUT"
+ 40 PRINT CHR$ (4),"READ INPUT"
+ 100 S$ = ""
+ 110 GET C$
+ 120 IF ASC (C$) = 13 GOTO 200
+ 130 S$ = S$ + C$
+ 135 GET D$
+ 140 GOTO 110
+ 200 V = VAL (S$)
+ 205 GET D$
+ 210 IF V = 0 GOTO 300
+ 220 CURR = CURR + V
+ 230 GOTO 100
+ 300 IF MOST < CURR THEN MOST = CURR
+ 310 CURR = 0
+ 320 PRINT MOST
+ 330 GOTO 100
+ 900 PRINT CHR$ (4),"CLOSE"
+ 910 END
+
diff --git a/day1/part2.bas b/day1/part2.bas
new file mode 100644
index 0000000..4ea4835
--- /dev/null
+++ b/day1/part2.bas
@@ -0,0 +1,30 @@
+REM Advent of Code 2022: Day 1, part 1
+REM Written in Applesoft BASIC
+
+ 10 ONERR GOTO 900
+ 20 DIM CALS(200):CURR = 0
+ 30 PRINT CHR$ (4),"OPEN INPUT"
+ 40 PRINT CHR$ (4),"READ INPUT"
+ 100 S$ = ""
+ 110 GET C$
+ 120 IF ASC (C$) = 13 GOTO 200
+ 130 S$ = S$ + C$
+ 135 GET D$
+ 140 GOTO 110
+ 200 V = VAL (S$)
+ 205 GET D$
+ 210 IF V = 0 GOTO 300
+ 220 CURR = CURR + V
+ 230 GOTO 100
+ 300 FOR I = 0 TO 5
+ 310 IF CURR = CALS(I) GOTO 360
+ 320 IF CURR < CALS(I) THEN NEXT I
+ 330 FOR J = 3 TO I STEP - 1:CALS(J + 1) = CALS(J): NEXT
+ 340 CALS(I) = CURR
+ 350 PRINT CALS(0),CALS(1),CALS(2)
+ 360 CURR = 0
+ 370 GOTO 100
+ 900 PRINT CHR$ (4),"CLOSE"
+ 910 PRINT CALS(0) + CALS(1) + CALS(2)
+ 920 END
+
diff --git a/day1/proof.jpg b/day1/proof.jpg
new file mode 100755
index 0000000..87ef51d
--- /dev/null
+++ b/day1/proof.jpg
Binary files differ