Topic 3 of 5 · 4 min read
Writing code first, then comparing
Goal: Write your own solution first, then use the AI version to name one real improvement and one thing the AI got wrong.
Write your own solution first, even a rough one, and only then ask for the AI version, so the comparison shows you something real.
Check yourself · 1 of 3
Why turn off inline autocomplete while you are learning to code?
Why it matters
If the AI's answer is the first thing you see, your own thinking never starts. You edit and accept instead of solving. Coding is a skill like playing an instrument: you improve by producing, not by watching. Autocomplete in the editor does the same thing in small pieces. It finishes your line before you decided what the line should be.
Your own attempt also gives you something to compare. When you place your code next to a stronger version, the differences are specific: a loop became a built-in, an edge case got handled, a name got clearer. Those are lessons you can reuse.
How to do it
- Turn off inline autocomplete while you practise (Copilot, Cursor Tab and similar tools all have a switch). Keep chat on if you want it.
- Write the solution yourself. Set a time box, such as 20 minutes. It may be ugly or incomplete. Save it.
- Run it on a few inputs, including an empty one.
- Ask for a review, not a rewrite. Paste your code and the task. Ask: "Name the two most important changes, with a reason for each. Do not show a full rewrite."
- Then ask for the AI's version and compare. Write down one improvement you will adopt.
- Check the AI for errors too. Ask yourself what its version assumes. Run it on the same inputs. AI code often looks cleaner and still fails on an edge case your version handled.
Before and after
Before: Write a function that returns the longest word in a sentence.
You paste the result and ship it.
After: Here is my function and the task. Review it. Give me two concrete changes with reasons, and tell me one input where it fails. Do not rewrite it yet.
An engineer's example. Your version:
def longest(sentence):
best = ""
for w in sentence.split():
if len(w) > len(best):
best = w
return best
A good review points out that max(sentence.split(), key=len) is shorter. A good comparison also notices that the AI version crashes on an empty string, where yours returns "". You learn from both.
What goes wrong
- Writing nothing, then "comparing". If you skim the AI's code and say "mine would be about the same", you did not attempt it.
- Asking for a rewrite. A full rewrite hides which change mattered. Ask for named changes.
- Treating the AI version as the answer key. It is another attempt. It can be wrong, over-clever or built for a different version of the language.
Examples
Review prompt that names changes
Prompt: Here is my solution to the task "count how many times each word appears". Name the two most important changes, each with a reason. Then give one input where my code gives a wrong result. Do not show a full rewrite.
You get specific feedback on your own code, and you decide which change to apply.
Catching the AI's mistake
Your loop returns 0 for an empty list. The AI's sum(xs) / len(xs) raises ZeroDivisionError on the same input. Writing first gave you a baseline that exposed the AI's gap.
Key points
- Write a rough solution yourself before you look at any AI version.
- Turn inline autocomplete off while practising, because it decides lines before you do.
- Ask for a review that names two or three concrete changes with reasons instead of a rewrite.
- Run your version and the AI version on the same inputs, including an empty one.
- Treat the AI version as another attempt that can fail on edge cases.
Common mistakes
- Keeping inline autocomplete on and calling the result your own attempt.
- Asking for a full rewrite, which hides which change mattered.
- Skimming the AI code and assuming yours would have matched.
- Assuming the AI version is correct because it looks cleaner.
Check yourself · 2 of 3
You wrote a solution and want feedback. Which request teaches you the most?
Check yourself · 3 of 3
The AI's version is cleaner than yours but crashes on an empty list, where yours works. What does that show?
Practice items, not counted towards your mastery.
Start here
- How AI assistance impacts the formation of coding skills (Anthropic) (opens in a new tab)ArticleFree
A randomized trial of 52 developers learning a new Python library: delegating to AI lowered comprehension, asking for explanations did not.
- Output styles, including the learning style (Claude Code docs) (opens in a new tab)DocsFree
How to switch Claude Code to the Learning style, which explains choices and leaves small pieces for you to write.
- CS50.ai, the CS50 duck tutor (Harvard) (opens in a new tab)ToolFree
A tutor built for beginners that guides with questions and hints rather than finished solutions.