{ datagubbe }


datagubbe.se » AoC 2021 Three Ways

Advent of Code 2021: Day 1 Three Ways

True to tradition (further evidence here), I decided to solve the first day of this year's Advent of Code on my Amiga. I didn't stop there, however. As previously explained, I've been bitten by some kind of mainframe bug and also made an attempt in COBOL. But first of all, I solved it in Python. The three solutions are quite similar in their approach, yet I think they showcase some of the fundamentals and particularities of each language in a nice way.

Python

Quick, dirty and compact with one-letter variable names. Just the way I like it - except when trying to understand it again ten months from now.

COBOL

An attempt was made. I've only written a handful of short programs in COBOL, and I'm sure someone with more experience in this curious language can produce a more elegant result. In any case, here it is. I compiled and tested it with an old version of GNU COBOL. So old, in fact, it's actually called Open-COBOL - but then again, isn't that in keeping with the whole shtick?

ARexx

Feeling a bit more at home here than in COBOL. Not unlike COBOL, ARexx is somewhat limited when it comes to built-in data structures - but ARexx' stems are still much nicer to work with than COBOL's tables. I wrote the code in Commodore's Amiga-ized version of MicroEmacs from 1987. Still does the job!

On my Amiga 1200 with a 14 MHz 68020 CPU and 4 megabytes of 32-bit RAM it takes about 20 seconds to solve part A and 57 seconds to solve part B, for a total runtime of 1 minute and 17 seconds.