It ran, and it gave you an answer. An answer is not a right answer — and the input you tried is the one you already had in mind.
The same script, the same day. The only difference is whose name went in.
sendInvite("John Smith") — runs, sends, returns success.
sendInvite("José García") — crashes on the encoding.
Working is a fact about one run. Correct is a claim about every run you have not done.
Working is a fact about one run. Correct is a claim about every run you have not done. The test you reach for first is always the case you already had in mind, which is why it passes.
And the dangerous version does not crash. Skipped rows, dropped decimals and a weekend deadline all produce output — a wrong number looks exactly like a number.
Tap an input, then tap whether the code survives it. Then see exactly what each one does to it.
Pick a situation. In every one, the tested input was the ordinary one.
It did not fail. It returned a smaller number, and a smaller number looks exactly like a number.
Five questions. Nothing is scored.
Five terms, not two. Tap one.
Working code is code that runs successfully in one observed case—often the example you gave the AI. Correct code is code that meets the full requirements and works across all valid inputs, not only the one you tested. The difference matters when your data or situation changes.
AI models often produce code that matches the example you provide. If your example is too narrow, the code may only work for that specific case. Without more details, the AI cannot anticipate every valid input or requirement.
Yes. Even if the code runs, you need to check it against your requirements and test it with different inputs. AI does not know your full context unless you spell it out.
No. A single successful run only shows the code worked for that input. Correct code needs to handle all valid cases, including those you have not tested yet.
You receive a script from an AI assistant that processes your sales report perfectly. When your colleague tries it on her report, it crashes because her file has an extra column. The code worked for you, but was not correct for all cases.
On the surface, both look like they do the job. If you only see one successful run, you might assume the code is reliable. Only when you try new data or requirements do the gaps show up.
Requirements describe what the code must do and what situations it must handle. If the code only works for one case, it is not meeting the requirements. Correct code covers all the rules and cases you set.
Yes, if you extend it to handle all valid cases and meet all requirements. Often, you start with working code and improve it until it is correct.
No. Correct code meets the stated requirements and handles all valid cases, but it might not be optimised for speed or style. Perfection is not the goal—reliability is.
No. If the requirements are vague or missing, the AI can only guess what you want. Clear requirements are needed for correct code.
An edge case is an unusual but valid situation—like a blank value or a very large number. Correct code handles these cases, while working code often misses them.
Testing with different inputs and scenarios shows whether the code only works for one case or for all the cases you care about. It is the fastest way to spot gaps.
No. A single success does not guarantee reliability. Production code needs to be correct—able to handle all valid cases and meet your requirements every time.
One green run tells you about one input. Correct is a claim about all of them.
Copyright © Pawan Nayar · LLOS.ai · 2026 — Working code vs Correct code: it ran once, versus it holds for every real case.Original pedagogy, voice, and design — all rights reserved.