OpenAI Interview Question

Multi-step coding question. Didn't finish the second part. Got rejected.