AI Reasoning in Code Generation and Debugging: A Deep Dive