Fix & Extend a Codebase: Orders, Gym & Players
- Read an unfamiliar class fast and find the bug a failing test points at
- Fix code without editing the tests, then extend it instead of rewriting it
- Work the restaurant, gym, players and log tasks in runnable code
- Pace the Karat coding block so every part gets a passing test
For experienced developers, Citi's coding round most often hands you code someone else wrote. In the Karat hour, after the quick questions on your stack, you get a small project with a few classes and unit tests, and some of those tests fail. You fix the bug without touching the tests. Then you fill in TODO methods or add a feature until everything passes. Java, Python and Go versions have all come up, and no part of the hour comes up more often.
Some US Java teams run the same idea for longer. A candidate booked for a two-hour Codility session in November 2026 was told to expect a codebase, JUnit tests to write and theory questions. Another described that session as a Spring application with planted bugs. The bugs people name are small: a missing OR, a wrong data type, an edge case nobody handled.
This lesson works four tasks of that shape, newest first. Three are from July 2026. There's a restaurant order delivery system with a bug and three improvements, a gym membership system to extend after you spot its design flaws, and a players-and-games task where managers calculate average scores. The fourth, from November 2025, is a log file to parse. Each problem below is something like the task, built for practicing the shape.
The first three start from existing code. Open the Python or Java starter and you'll find a class that mostly works, a bug or a design flaw, and TODO comments where the new work goes. That's how the real round sets it up. Run the tests first and let the failures tell you where to look.
How to work a codebase you have never seen
Read the tests before the code. Their names tell you what the class promises, and the failing ones tell you where it breaks. Then read only the method a failing test calls, top to bottom, and say what you expect it to do. Where the code disagrees with you is usually the bug. One Python candidate put the whole project at 100 to 150 lines. That's small enough to skim in a few minutes if you skim with a question in mind.
Leave the tests alone. The instructions say to make them pass without changing the test class, and editing an assertion to match broken code throws away the exercise. Make the smallest change that fixes the behavior, rerun everything and say what you changed.
When the extension starts, build on the design you were given. Say the code keeps plan rules in an if-chain and you need a new plan. You can add one more branch, or you can move the rules into a table. Say which you'd pick and why, then do it. The gym candidate said that round was about code quality and object-oriented design, and a rewrite from scratch eats the minutes the later parts need.
A failing test is a bug report with a reproduction attached. Read its name, its input and its expected value before you open the class. Most of the time you'll know which method to read and roughly what's wrong with it before you scroll.
A restaurant order delivery system with one bug and three improvements
In July 2026 a senior software engineer in the UK had a Karat first stage that opened with five Java theory questions, on data structures, final and exceptions. Then came the coding. The task was to resolve a bug in a restaurant order delivery system and make three improvements. The class below is something like it. Its bug is a missing OR, one of the bugs other Karat candidates name.
Fix and Improve a Restaurant Order System
Problem
DeliverySystem takes a menu that maps each item to its price in cents. Calling place_order(order_id, items) stores the order as PLACED and returns its total. Calling advance(order_id) moves an order one step along PLACED, PREPARING, OUT_FOR_DELIVERY and DELIVERED and returns the new status. The status(order_id) method returns the current status, and cancel(order_id) returns whether it cancelled.The kitchen reports a bug. A customer may cancel while the order is PLACED or PREPARING, but cancelling a PREPARING order fails. Fix it without changing the tests.
Then make three improvements. First,
place_order returns -1 and stores nothing for a repeat id, an empty item list or an item not on the menu. Second, an unknown id gives "UNKNOWN" from status and advance and false from cancel, and a DELIVERED or CANCELLED order no longer moves. Third, add active_orders(), the ids of orders still in flight, in the order they were placed.- DeliverySystem({"burger": 850, "fries": 300, "soda": 200})
- place_order("o1", ["burger"])→ 850
- advance("o1")→ "PREPARING"
- cancel("o1")→ true
- status("o1")→ "CANCELLED"
The order is still in the kitchen, so it can be cancelled. The original code returns false here.
Read cancel against the bug report first. Every improvement after that is a guard at the top of a method, or a filter over the orders dict, which already keeps placement order.
Fix and Improve a Restaurant Order System
Click "Run" to execute your code
A gym membership system: spot the design flaws, then extend it
Also in July 2026, a senior Java developer in the US had a first technical round that opened with Java and object-oriented questions such as hashCode versus equals. Next came identifying design flaws in an existing codebase. The coding meant extending and modifying an existing Java application for a gym membership system, instead of solving a problem from scratch. According to the candidate, the focus was code quality and object-oriented design. Below is something like it, with three flaws planted for you to find.
Extend a Gym Membership System
Problem
Gym already supports join(member_id, plan, day), which returns false for someone who already joined, and check_in(member_id, day, hour). A membership runs for 30 days from its start day. BASIC members may check in from hour 6 up to but not including 22, and PREMIUM members at any hour. monthly_fee(member_id) returns 25 for BASIC and 45 for PREMIUM.The existing code has design flaws. Each plan's rules are split across two if-chains, an unknown plan can join and gets billed as BASIC, and a check-in before the start day goes through.
Extend it. Add an OFF_PEAK plan at 15 a month for hours 10 up to 16. For an unknown plan,
join returns false. Outside the 30 days from the start day check_in is false, and for an unknown member monthly_fee returns -1. Add change_plan(member_id, plan), which returns false for an unknown member or plan and keeps the original start day.- Gym()
- join("ana", "BASIC", 1)→ true
- check_in("ana", 5, 23)→ false
- check_in("ana", 30, 7)→ true
- check_in("ana", 31, 7)→ false
Hour 23 is outside BASIC hours. Day 30 is the last day of a term that started on day 1, and day 31 is past it.
Move every plan rule into one table keyed by plan name, holding the fee and the hours. Then join, monthly_fee, check_in and change_plan all read from it, and a new plan is one new row.
Extend a Gym Membership System
Click "Run" to execute your code
Players, games and manager averages
In July 2026 a senior software engineer in Toronto had a Karat round that opened with Angular knowledge questions. The coding was a practical multi-step task about players and games, where managers calculate average scores, and the candidate summed it up as practical and not LeetCode style. The version below builds something like it in three steps, starting from a class with two bugs.
Player and Manager Average Scores
Problem
League records games and answers questions about scores. The record_game(game_id, scores) method takes a dict from player to points and returns true. Calling assign(player, manager) puts a player on a manager's roster, and assigning again moves them. Finally, average(player) returns the mean of the player's scores, rounded to two decimals, or 0.0 if they have none.Two bugs are reported.
average returns 10 for scores of 10 and 11, and a game recorded twice under the same id counts twice. Fix both, and make record_game return false for a repeat id.Then add two steps. The first,
team_average(manager), is the mean of every score posted by that manager's players, rounded to two decimals, or 0.0 when there are none. The second, rank_managers(), lists the managers with at least one score, highest team average first, ties broken by name.- League()
- record_game("g1", {"ana": 10, "ben": 5})→ true
- record_game("g2", {"ana": 11, "ben": 6})→ true
- average("ana")→ 10.5
- average("ben")→ 5.5
The original code floors 21 / 2 to 10 before rounding.
Keep every score per player and compute averages when asked. A team average adds raw points and counts across the roster, so a player with ten games weighs more than a player with one.
Player and Manager Average Scores
Click "Run" to execute your code
int / int drops the fraction before you round. Before step two, ask whether a team average means the mean of all scores or the mean of player averages. They differ as soon as players have different game counts. Pick one, say it out loud, and code it.Parse a log file and pull out the data points
The oldest task here is from November 2025. A senior cloud engineer in Belfast had a 90-minute first interview that mixed coding with Kubernetes. The candidate described the coding as pulling data from a log file and analysing it, or pulling out specific data points. The problem below is one common version of that task. You count log lines at a level for each service and skip whatever doesn't parse.
Count Log Lines by Service
Problem
Write
count_by_service(lines, level). Count the lines at level for each service and return strings like "payments 2", highest count first, ties broken by service name.Skip lines that don't parse. That means blank lines, lines with fewer than four fields, and lines whose level isn't one of the four.
The garbage line has two fields and is skipped. The WARN line is the wrong level.
Split each line on whitespace and check the field count and the level before you trust anything. Count with a dict, then sort by negative count and name.
Count Log Lines by Service
Click "Run" to execute your code
What earns points in the fix-and-extend round
The same habits score across all four tasks. Read the tests first. Fix with the smallest change that makes sense and leave the tests alone. Extend the structure you were given, and when its design gets in the way, say so and fix that one thing. Talk while you work. Karat rounds are recorded and sent to Citi's recruiter, so reasoning you say out loud ends up on the record.
Common questions
What coding questions does the Citi Karat interview ask?
Most often a small project with failing unit tests. You fix the bug without editing the tests, then fill in TODO methods or add a feature. Named tasks from July 2026 include a restaurant order delivery system, a gym membership system and a players-and-games average. Some rounds swap in short snippets to read instead, and a few have ended with easy LeetCode problems like a palindrome check.
Can I code in Python if the role is Java?
It has been allowed. A Mississauga candidate in October 2025 used Python for a Java role and passed, and a Singapore round in July 2026 let the candidate pick the language for the implementation question. The knowledge questions still follow the job post, so a Java role still gets Java questions. Confirm with your recruiter before the day.
How long do I get for the coding?
In the Karat hour, roughly the last 30 to 40 minutes. Some US Java teams use a longer Codility session instead. One booked for November 2026 ran two hours, with a codebase, JUnit tests to write and theory questions.
How should I practice these?
Do each task here on a timer, starting from the starter code, and run the tests before you read the class. Then practice on code you've never seen. Open a small project, pick a failing test or a TODO, and time how long it takes to find the method that matters. The Citi Karat interview lesson covers the stack questions that come first.
Key Takeaways
- ✓Citi's Karat coding block is usually someone else's code. Fix the failing tests without editing them, then fill in TODOs or add a feature.
- ✓Read the failing tests first. Their names and inputs point at the method, and often at the line.
- ✓Extend the design you were given. When it fights you, name the flaw and fix only that.
- ✓Pace for every part. Candidates who felt finished have still been turned down within a day.
Citi interview guideKnow what Citi asks before you walk in.
26 coding · 6 system design · 20 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.