It's worth noting that there are several problems with the function ChatGPT provided. While it did address (to some degree) the one issue I raised immediately, it still produces a failing implementation, even according to its own examples.