in reply to
Can you spot the problem?
I have to admit that trying to solve puzzles like this pre-coffee are not the best idea. I looked at this for a while, and saw the problem. But I wasn't sure I saw the problem, so I started running the code.
Even knowing the problem, I couldn't find a good test case to make this fail until I looked at some of the other notes -- I'd become convinced that I was wrong about the problem. But my initial guess was correct.
So no cookie for me. But I'll settle for my coffee instead.