21
๐ฆ - 2023 DAY 9 SOLUTIONS -๐ฆ
(programming.dev)
An unofficial home for the advent of code community on programming.dev!
Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.
Solution Threads
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 18 | 20 | 21 | 22 |
23 | 24 | 25 |
Icon base by Lorc under CC BY 3.0 with modifications to add a gradient
console.log('Hello World')
Algol 68
So this felt like an old-school programming challenge. Like the type of thing you'd give to a CS student back in the good old days. So I decided to code in the granddaddy of modern languages. I did this in Algol-68!
In fact, Algol 68's event driven input handler was quite nice for this task as was its easy ability to detect the ends of lines. of course, its lack of built-in data structures meant that I had to whip up my own dynamic array, but that's pretty easy too. If you read today's code, you'll see familiar threads that influenced C and most of the languages that followed it.
Algol 68 is meant to be a language for publication. It is really tough to write a compiler for this language, but it is easy to write self-documenting code. In fact, a lot of textbooks publish algorithms in pseudocode that is almost correct Algol 68 code! So I tried to write today's solutions with readability in mind. Of course, this venerable language is not without its flaws, but I do enjoy coding in it from time to time.
https://github.com/pngwen/advent-2023/blob/main/day-9a.a68
https://github.com/pngwen/advent-2023/blob/main/day-9b.a68