Also, as much as i love your solution, i think it's hard to argue that it's simpler than something like this boring procedural loop:
bit.ly/2E8mZ8F. And usually it's the other way around: ie, the J framing and solution of a problem actually simplifies it conceptually, as well as making it shorter.