Ahhh yes. I have been playing a little to try and understand how your code works; making temporary hard-code changes, running it and learning from the outcome. This is one I hadn't yet changed back to your code.
I'll add a sample expected result as you suggest.