← 返回 scale.ai 的题目列表Debug a Multi-File Project Assignment System (Fix Failing Tests)
类型:online_judge
Problem: Debug and Fix a Multi-File Project Assignment System (Make All Failing Tests Pass)
You are given a codebase with 10+ source files (including several CSV data files). The codebase implements a business flow for assigning projects. Your goal is to read the code, run tests, add prints/logs as needed, and fix the implementation so that all tests pass.
What you observe
There are 3 failing tests.
During the interview you can open files, run the test suite, and use print/log statements to inspect intermediate states.
The interviewer may provide hints, but the main focus is your debugging process and communication.
Known likely defect patterns (based on the failure points)
You need to locate and fix issues similar to the following (not guaranteed to be exactly these; follow test expectations):
Wrong boundary check for available headcount:
The intended behavior is: a project is assignable only when project.available_headcount > required_headcount (or equivalent).
The code likely uses >= instead of > (or vice versa), causing incorrect behavior on boundary cases.
Wrong sorting order for project priority:
Expected: sort by priority in descending order (higher priority first).
Actual: implemented as ascending, leading to wrong assignment order.
Filtering uses the wrong field (courseid vs id):
A filter should be applied based on courseid, not id.
Using the wrong field produces an incorrect filtered set.
State not reset inside a loop:
Inside a for loop, a state/counter/accumulator variable must be reset per iteration.
The code forgets to reset it, so later iterations are contaminated by previous state.
Your task
Run the tests and narrow down each failure.
Update the code (possibly across multiple modules/files) so that:
behavior matches test expectations
all tests pass
Constraints
Do not modify tests to make them pass (unless explicitly allowed; assume not allowed here).
You may add logging while debugging, but the final submission should pass tests without manual intervention.
Explain clearly how you:
narrowed down the root causes
validated each fix
This is a debugging-style interview question focusing on code reading, diagnosis, edge cases, and communication.