Advent of Code 2020 in Fortran 77 (mostly)
It’s rained nearly every day since the start of 2026 in Devon. On January 27th the River Otter reached it’s highest recorded level. The picture below was taken from the footbridge in Ottery St Mary that afternoon. The river was around a metre off its peak at this point, but was still a couple of metres deeper than normal and over twice as wide.

All the bad weather has meant that it’s been difficult to do very much outside, so I’ve been entertaining myself working through 2020’s Advent of Code using (mostly) Fortran 77. I finished the final puzzle this afternoon and that appears to have signalled a change in the weather for tomorrow! My solutions and commentary are in this repository, so I don’t intend to go into a blow-by-blow discussion here.
I think the solutions that I’m happiest with are those for day 19 and day 24. Day 19 was fun, as I realised early on that the puzzle was about parsing a context free grammar. The design decisions I took in part 1 made part 2 straightforward. It’s good that Fortran 77 doesn’t have a regular expression capability as standard, because although an approach based on regex would have worked for part 1 it would not have been much fun trying to get part 2 to work that way.
Day 24 required a little thinking before realising that a hex coordinate system was needed. Creating an implementation of the Hexagonal Efficient Coordinate System was fun. The code isn’t the most compact I could have written but is very readable. The ‘Life’ algorithm required for part 2 was also interesting to write, even after implementing a ‘Life’ algorithm in 3D and 4D for day 11.
The most frustrating puzzle was definitely that set for day 20. Part 1 wasn’t too bad and I found a shortcut to find the four corners of the jigsaw without having to completely assemble it. Part 2 wasn’t so forgiving and is over 450 lines of code! It’s fortunate that the tiles all have unique edge matches with other tiles, otherwise I’d still be writing a solution now. I did manage to take liberties with the now deprecated EQUIVALENCE statement to map 2D grids onto 1D arrays and also use a DATA statement, so I certainly stretched Fortran 77 to the maximum.

With the exception of dipping into recursion for a couple of problems, all of the code I wrote should work happily on any 32 bit compiler (such as Sun’s) of the early 80s. I suspect even the recursion will work on the Sun Fortran compiler if the Fortran 90 RECURSIVE keyword is omitted.
One thing I was asked about while working through the puzzles was why I use STOP 8 to indicate a serious failure has happened. It’s simply that STOP 8 was the most frequent error message that the PAFEC DOGS computer aided design system spat out when something had gone horribly wrong! DOGS was the first commercial software suite that I ever wrote code for, so that error code will stay with me forever.