Good analysis. Didn't Knuth famously say that his job was to get to the bottom of things, not to stay on top of things?
If I were writing a one-off program to do this once for a paid project, the shell script is absolutely the way I would go about it.
If I were writing it as a computer scientist, accustomed to teaching students how to find optimal solutions, something like the Knuth program is absolutely the way I would go about it (although in 2020, I would likely use C, not Pascal). I also would likely roll my own approach if I was writing it for the kind of target machine I work on now - a very small one (an embedded microcontroller). And Knuth made his bones when computers were (physically) huge but (in memory and speed) tiny.