Took me an embarrassingly long time to find it.
Start by reproducing the bug with a minimal test case, then trace the data flow from parsing to the speed calculation. Inspect the time-delta computation and unit conversions, as the bug likely lies in how timestamps are parsed or subtracted. Fix the issue and write a focused unit test that verifies the time-delta math independently.
Pro tip: Demonstrate a systematic debugging process: form a hypothesis, test it with a minimal reproduction, and verify the fix with a targeted test. This shows you can isolate and resolve issues efficiently, a key skill for production code.
Create a minimal LogEntry with clearly speeding data and run catch_speeders to confirm it fails to flag the vehicle. This establishes a baseline and ensures you understand the expected behavior.
Follow the parsed values from the LogEntry constructor through to the speed calculation. Check for incorrect parsing (e.g., timestamps as strings), unit mismatches, or integer division that could zero out the speed.
Focus on how the time difference between entries is computed. Look for off-by-one errors, incorrect timestamp formats, or missing conversions (e.g., milliseconds vs. seconds).
Apply the fix, such as converting timestamps to a consistent unit or correcting the subtraction order. Re-run the reproduction to confirm the vehicle is now flagged.
Write a small test that isolates the time-delta calculation, using known timestamps and asserting the expected difference. This prevents regressions and documents the correct behavior.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.