Day 1 of the Advent of Code consisted of two parts. You had to finish part one before you could advance to part two, plus you had to log in using OAuth (with a Google, Twitter, or Reddit account).

In part one there was a list of character strings, which I separated by commas (to avoid character return issues between platforms), and for which the first and last digit in each character string formed a two-digit number. All the two-digit numbers had to be added up into a total sum, which was the solution to part one.

As a first attempt, I compiled the list as follows:

*= $2000

.byte "…"
.byte 0

where the stands for the list of comma separated items.

I compiled the source code file to a .PRG file, using Virtual 6502 Assembler, and loaded the resulting file into the V.I.C.E. emulator on my Raspberry Pi 400, running Raspberry Pi OS. This took a couple of minutes, since it was a large file (21 Kb) for such a small retro computer.

Next, I lowered the end of Basic memory, and wrote the following CBM Basic 2.0 program:

poke 56,32:new: rem lower end of basic memory to $2000

10 ad=8192:rem decimal of $2000
20 sm=0:n=0:rem total sum of 2-digit values, number of items
30 f=-1:l=-1:p=0:rem first, last digit, 2-digit value
40 c=peek(ad)
50 if c=0 then end:rem zero value signals end of file
60 if c=asc(",") then 120:rem comma separated list
70 if c<asc("0") or c>asc("9") then 110:skip for non-digits
80 v=c-asc("0")
90 if f<0 then f=v:rem -1 signals no digit found
100 l=v
110 ad=ad+1:goto 40:rem do next character
120 n=n+1:rem count number of items
130 if f<0 then 150:rem skip non-digits
140 p=f+10*l:sm=sm+p:print n,p,sm
150 ad=ad+1:goto 30:rem do next item

Running in Warp mode took a few minutes, and the resulting last line was:

999 66 54727


Apparently, there were 999 items, where the sum of the two-digit numbers was 54727. I checked my code, and reran the Basic program, same result (of course).

Anxiously, I entered the result into the answer box on the website. It turned out my answer was wrong. It was too high.

Ah well, this was to be expected. Now I have to reread the instructions to see if I perhaps misunderstood, then debug and find a better solution. Maybe I need to start smaller, instead of using the entire list.

I think it was a valiant first attempt. Coding is hard, after all.