Thanks for all your insights, David. This is a really awesome solution. It didn't quite occur to me that I could have two separate accumulator loops (forward and reverse), and then combine the results like this.
You're definitely welcome to write this up in a post. That would be super interesting.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.