Replanning When Requirements Change

Topics Covered

What the Twist Is For

Why interviewers use a twist

What changes and what does not

The common shapes of twists

The first minute

An example twist in Python

An example twist in TypeScript

An example twist in Java

A sample exchange

Summary

Twists in larger codebases

When the twist conflicts with your earlier choices

Managing time after the twist

Staying calm

What not to do

Most AI assisted coding rounds include a twist: partway through, the interviewer changes or extends the requirements. A list that was sorted one way must now be sorted another. A function that handled one item must now handle many. A rule that had no exceptions gains one. The twist is not a trick. It is the part of the round that most closely resembles real engineering work, where requirements change after code exists, and it is often where the strongest signal comes from.

This lesson covers how to respond to a twist: stop and read the new requirement, diff it against the old one, trace its impact, work examples by hand, decide whether to patch or reshape and check any assistant patch against those examples. The next lesson covers making the change itself in small, safe steps.

The twist changes the rule after you have built on the old one.

Why interviewers use a twist

A twist tests things that the first part of the round cannot. Can the candidate understand a new requirement precisely, rather than approximately? Can they see which parts of the existing code depend on the old requirement? Can they change working code without breaking what still matters? Can they direct an assistant through a change, rather than only through a fresh build? And can they keep their head when the plan they were following no longer applies?

In AI assisted rounds, the twist is especially revealing, because assistants are fast at producing a patch and the patch often looks right. The candidate's job shifts from producing code to judging whether a quick change actually implements the new rule. Candidates who accept the first patch that keeps the visible tests green often do worst on the twist.

What changes and what does not

A twist rarely invalidates everything. Usually one or two clauses change and the rest stay the same. The skill is to identify exactly which clauses changed, so you change only what you must and keep the rest protected by existing tests. Candidates who treat the twist as a fresh problem often rewrite code that was fine and introduce new bugs. Candidates who treat it as a small patch, without checking how deep it goes, often miss places where the old assumption is baked in.

The common shapes of twists

Twists come in a few common shapes. A change to an ordering or tie rule. A new input condition, such as negative values or duplicates being allowed. A change of scale, such as many queries instead of one, or a stream instead of a list. A new output field or format. A new exception to an existing rule, such as a discount that does not apply to some items. A change in how state is kept, such as remembering history or allowing undo. Recognising the shape quickly helps you know where the impact is likely to fall.

The first minute

When the twist arrives, the first minute matters most. Do not type. Read the new requirement twice. Ask any immediate clarifying question. Then say back, in a sentence, what has changed: so previously each item had its own position, and now equal items share one, with the next position skipping ahead. Saying it back confirms your understanding and shows the interviewer you have absorbed the change before acting.

An example twist in Python

The original rule: compute the shipping fee for an order as a flat five dollars plus one dollar per item.

The twist: orders over fifty dollars ship free, except that heavy items always cost three dollars each to ship.

python
def shipping_fee(order):
    return 5 + len(order.items)

The twist changes the formula, adds a threshold that depends on the order total and adds an exception for heavy items that survives the threshold. A quick patch that returns zero over fifty dollars misses the heavy item exception. Reading the twist carefully reveals two new clauses, not one.

An example twist in TypeScript

The original rule: return the titles of upcoming events, sorted by start time.

The twist: events can now be cancelled, and cancelled events should be excluded; events with the same start time should be ordered by title.

Two changes in one twist, a filter and a tie rule. The filter is easy to see. The tie rule is easy to miss, because the existing tests probably have no events at the same time.

An example twist in Java

The original rule: a method returns the average grade for a student across all their courses.

The twist: courses now have credit weights, and the average must be weighted by credits; courses with zero credits are excluded.

The averaging formula changes and a new exclusion appears. The zero credit exclusion also protects against division by zero when every course has zero credits, a case the twist does not mention and you should ask about.

A sample exchange

Interview Dialogue

InterviewerClick to reveal answer
CandidateLet me make sure I have it. Over fifty, the flat fee and per item fee go away. Heavy items still cost three each, whatever the total. Under fifty, is a heavy item charged the normal one dollar plus the three, or three instead?
InterviewerClick to reveal answer
CandidateThanks. So two new clauses: the free threshold and the heavy item price, which applies in both cases.
Show all answers

The candidate said the change back, found an ambiguity in the first minute and named the clauses before touching code.

Summary

The twist tests understanding, impact analysis and controlled change. Do not type in the first minute: read twice, ask, say back what changed and name the clauses involved.

Twists in larger codebases

In a codebase round, the twist often arrives as a new ticket or a message from a pretend product manager rather than a single changed sentence. It may be several paragraphs long and mix the real change with background. Read it for the clauses, not the story. Underline each sentence that changes what a function must return or how state must behave, and set aside the rest. Most long twists reduce to two or three clauses once the context is stripped away.

When the twist conflicts with your earlier choices

Sometimes the twist makes an earlier decision look wrong: you chose a list where a map would now fit, or you computed a value once where it must now be recomputed. This is normal and not a failure. The interviewer chose a twist that stresses the original design, often deliberately. Acknowledge it briefly, this changes the case for the list I chose, and move on to deciding how to adapt. Defending the earlier choice wastes time; quietly working around it creates layered special cases.

Managing time after the twist

The twist usually arrives with twenty to thirty minutes left. Budget roughly five minutes for reading, diffing and examples, fifteen for the change and its checks and five for a summary. If tracing shows the change is larger than that budget allows, say so early and agree a scope with the interviewer: I can implement the threshold and the heavy rate fully, and I will describe how the receipt display should change if there is not time to do it. A stated scope is far better than an unfinished change discovered at the end.

Staying calm

A twist can feel like the plan you were following has been taken away. The routine in this lesson replaces it with a new one: read, say back, diff, trace, examples, decide, change, check. Having a routine to fall back on is what lets strong candidates stay calm. Practise it on enough problems that it runs without thought.

What not to do

Do not start typing in the first minute. Do not ask the assistant to implement the twist from its wording alone. Do not accept a patch because the visible tests still pass. Do not rewrite code that the twist does not touch. And do not silently change visible tests to make a patch pass.

Do not type in the first minute

Read the twist twice, ask any immediate question and say back what changed. A minute spent understanding the twist precisely saves far more time than a fast patch built on an approximate reading.