Library › Coding AI › Software developers
Check an AI-written function against its requirements
- For Software developers
- You practice Catching mistakes and made-up facts
- Time about 5 minutes
About this exercise
A coding assistant wrote an average function and says it meets all 4 requirements. Check it by reading the code: write exactly 4 numbered lines, one per requirement in order, each labeled Met or Not met, then the line number and a reason in under 15 words. Don't rewrite the code and use no code blocks. Under 110 words.
Common mistakes when you ask AI for this
- Trusting the assistant's note. The note says everything is handled, and the AI agrees. Try: Add: "Judge only the code, not the note."
- Missing the in-place sort. sort() looks harmless, but it changes the caller's array. Try: Add: "Check whether any line changes the input array."
- No line evidence. The AI says 'fails R1' without pointing to where. Try: Add: "Cite the line number for each verdict."
- Rewriting instead of reviewing. The AI jumps to a fixed version in a code block. Try: Add: "Don't rewrite the code. No code blocks."
What a strong prompt includes
- Ignores the note
- Uses exact labels
- Asks for line numbers
- Bans rewrites
- Caps the length
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)