It's nice to have ChatGPT write you code but if you don't already understand how to write the code yourself you might not like the result. I also don't understand why it returns flawed results only to agree with you that it's not optimal/correct.