Sign in to track progress, unlock prep layers, and browse your pipeline.Sign in
Debug and extend obstacle-run statistics classes
Problem: Obstacle Course Run Statistics (Debug + Implement)
You are building software to track how long racers take to complete an obstacle course.
Domain Model
- A Course has:
title(string)obstacle_count(int): number of obstacles in the course
- A Run represents one attempt on a Course:
obstacle_times: list of per-obstacle completion times (seconds)complete: boolean that becomesTruewhenlen(obstacle_times) == course.obstacle_countadd_obstacle_time(t): appends a time for the next obstacle; throws if run is already completeget_run_time(): sum of the recorded times so far (for incomplete runs, sum of completed obstacles)
- A RunCollection stores many runs for the same course:
add_run(run): adds a Run; rejects runs from a different Coursepersonal_best(): the minimum total time among complete runs
Tasks
- Debugging:
- There is a bug in the provided
RunCollectionimplementation that causes an existing unit test to fail. - Fix
RunCollectionso that the provided test suite passes.
- There is a bug in the provided
- Implement
best_of_bests()inRunCollection:- Definition: the fastest possible run time if everything went perfectly.
- Compute it by taking, for each obstacle index
i, the minimum observed time for obstacleiacross all runs that reached that obstacle (including incomplete runs), and summing these per-obstacle minima. - Add (or update) a unit test verifying correctness.
- Implement
chance_of_personal_best(test_run)using simulation:- Input: an in-progress
Run(may have completed some obstacles but not all). - Assume that for each remaining obstacle
inot yet completed intest_run, the time to complete obstacleiis drawn uniformly at random from the set of historical times recorded for obstacleiin the run collection (including obstacle times from incomplete runs, as long as that obstacle time exists). - Run 10,000 trials:
- For each trial, sample times for the missing obstacles and add them to
test_run’s current elapsed time. - Count the fraction of trials where the completed simulated total time is <= the current
personal_best().
- For each trial, sample times for the missing obstacles and add them to
- Return that fraction as a float.
- Accuracy requirement: the returned value should be within ±0.02 of the true probability.
- Input: an in-progress
- Testing & Code Quality Discussion:
- What additional tests would you add (beyond the provided ones)?
- After implementing
best_of_bests()andchance_of_personal_best(), what improvements would you make to the codebase (structure, naming, performance, reliability, determinism of tests, etc.)?
Notes / Edge Cases to Consider
- Some runs may be incomplete.
personal_best()is defined only over complete runs.- The run collection is assumed to contain runs for exactly one course.
- Sampling for obstacle
irequires there to be at least one historical time recorded for that obstacle.
AI interview prep
Core dilemma
Balancing correctness and robustness of statistical computations (especially with incomplete data and edge cases) against performance and scalability for a growing collection of runs, while also designing a reliable statistical simulation.
Mid-level signals3
Senior signals3
Red flags4
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Debug and extend obstacle-run statistics classes
Problem: Obstacle Course Run Statistics (Debug + Implement)
You are building software to track how long racers take to complete an obstacle course.
Domain Model
- A Course has:
title(string)obstacle_count(int): number of obstacles in the course
- A Run represents one attempt on a Course:
obstacle_times: list of per-obstacle completion times (seconds)complete: boolean that becomesTruewhenlen(obstacle_times) == course.obstacle_countadd_obstacle_time(t): appends a time for the next obstacle; throws if run is already completeget_run_time(): sum of the recorded times so far (for incomplete runs, sum of completed obstacles)
- A RunCollection stores many runs for the same course:
add_run(run): adds a Run; rejects runs from a different Coursepersonal_best(): the minimum total time among complete runs
Tasks
- Debugging:
- There is a bug in the provided
RunCollectionimplementation that causes an existing unit test to fail. - Fix
RunCollectionso that the provided test suite passes.
- There is a bug in the provided
- Implement
best_of_bests()inRunCollection:- Definition: the fastest possible run time if everything went perfectly.
- Compute it by taking, for each obstacle index
i, the minimum observed time for obstacleiacross all runs that reached that obstacle (including incomplete runs), and summing these per-obstacle minima. - Add (or update) a unit test verifying correctness.
- Implement
chance_of_personal_best(test_run)using simulation:- Input: an in-progress
Run(may have completed some obstacles but not all). - Assume that for each remaining obstacle
inot yet completed intest_run, the time to complete obstacleiis drawn uniformly at random from the set of historical times recorded for obstacleiin the run collection (including obstacle times from incomplete runs, as long as that obstacle time exists). - Run 10,000 trials:
- For each trial, sample times for the missing obstacles and add them to
test_run’s current elapsed time. - Count the fraction of trials where the completed simulated total time is <= the current
personal_best().
- For each trial, sample times for the missing obstacles and add them to
- Return that fraction as a float.
- Accuracy requirement: the returned value should be within ±0.02 of the true probability.
- Input: an in-progress
- Testing & Code Quality Discussion:
- What additional tests would you add (beyond the provided ones)?
- After implementing
best_of_bests()andchance_of_personal_best(), what improvements would you make to the codebase (structure, naming, performance, reliability, determinism of tests, etc.)?
Notes / Edge Cases to Consider
- Some runs may be incomplete.
personal_best()is defined only over complete runs.- The run collection is assumed to contain runs for exactly one course.
- Sampling for obstacle
irequires there to be at least one historical time recorded for that obstacle.