That's a good attempt but the coroutine solution is incorrect. See if you can figure out why and how to improve it. You can also ask it to propagate constraints and see what happens.
I'll repeat what I said previously in a different way, LLMs are useful but they are nowhere near what is required to achieve generally intelligent software systems. I'm sure they will continue to improve as engineers and companies learn how to utilize them in their workflows but let's temper the hype a little bit because statistical autocompletion is not enough to achieve general intelligence.