ChatGPT wrote the function perfectly on the first shot, but then I realized it was only working most of the time -- turned out ChatGPT had done a really obvious off-by-one error in the loop, and it was breaking on (1/n) attempts where n is the size of the list.
It's exactly the same as how ChatGPT usually knows what formulas and approaches to take when solving graduate-level mathematics, and its reasoning about the problem is pretty good, but it can't get the right answer because it can't add integers reliably.
Something that experienced (and expensive) programmers are good at, incidentally.
Full transparency: I think I'm one of those bad programmers who is a good debugger, but I've also been a full-time Linux nerd since Ubuntu 8.04, so I'm very comfortable reading error messages.
And writing code is the easy part. Architecting is where things get tricky and there are a lot of subjective decisions to be made. That's where soft skills become really important.
Same with my junior devs