What a tragedy. I remember Bob’s code that generates certain numbers: https://www.beust.com/weblog/coding-challenge/. Bob’s code is in Java, yet uses clever backtracking techniques to achieve the best performance among many solutions in all kinds of languanges.
Huh, it seems Bob further optimized his code. The one I remember used the similar approach, but employed a doubly-linked list for backtracking. The pleasant surprise that I got from his code was that recursion plus a linked list still beat those "faster" languages, a classical example of optimizing algorithms first, as beautifully argued in Steven Skiena's Algorithm Design Manual
I ported his code to C++, the linked list version and the other recursive version. Then I removed the recursion. For me, the linked list is 2X slower and the non-recursive version using a stack is slightly faster than his original version.