Skip to content

Instantly share code, notes, and snippets.

@fastjack
Created December 3, 2023 13:13
Show Gist options
  • Save fastjack/3f5261b26ced9743ed6687f7fce3665c to your computer and use it in GitHub Desktop.
Save fastjack/3f5261b26ced9743ed6687f7fce3665c to your computer and use it in GitHub Desktop.
Advent of Code 2023, Day 1, Part 2
10 OPEN 1, 8, 3, "INPUT.TXT,S,R"
20 S = 0
30 INPUT#1, A$
40 GOSUB 100
50 S = S + C
60 IF ST = 0 GOTO 30
70 CLOSE 1
80 PRINT S
90 END
100 L = LEN(A$)
110 FOR I = 1 TO L
120 C1 = ASC(MID$(A$, I, 1))
130 IF C1 >= 48 AND C1 <= 57 THEN I = L
140 NEXT I
150 FOR I = L TO 1 STEP -1
160 C0 =ASC(MID$(A$, I, 1))
170 IF C0 >= 48 AND C0 <= 57 THEN I = 1
180 NEXT I
190 C = (C1 - 48) * 10 + C0 - 48
200 RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment