All MicroEvals
t3-01-repair-completion-ordering
Create MicroEval
Header image for t3-01-repair-completion-ordering

t3-01-repair-completion-ordering

T3-complex

Prompt

You are fixing a bug in a small C# file. Below is the full contents of `FleetCoordinator.cs`, followed by the bug report. Reply with ONLY the complete corrected contents of `FleetCoordinator.cs` in a single C# code block - no explanation before or after the code block. ## Current file: FleetCoordinator.cs ```csharp namespace FleetCoordinatorKata; public sealed class Drone { public required string Id { get; init; } public double Energy { get; set; } public double MaxEnergy { get; init; } public double RegenPerTick { get; init; } } /// <summary>Tracks which drones are currently docked for repair.</summary> public sealed class RepairQueue { private readonly HashSet<string> _inRepair = new(); public void Enqueue(string droneId) => _inRepair.Add(droneId); public bool IsInRepair(string droneId) => _inRepair.Contains(droneId); public void MarkComplete(string droneId) => _inRepair.Remove(droneId); } public static class FleetCoordinator { /// <summary> /// Advances one tick for every drone: applies regen, and for drones in the repair queue, /// marks repair complete (removing the drone from the queue) the moment the drone reaches /// full energy. A drone that reaches MaxEnergy on tick N must be marked complete on tick N, /// not tick N+1. /// </summary> public static void TickAll(IReadOnlyList<Drone> drones, RepairQueue queue) { foreach (var drone in drones) { if (queue.IsInRepair(drone.Id) && drone.Energy >= drone.MaxEnergy) { queue.MarkComplete(drone.Id); } drone.Energy = Math.Min(drone.Energy + drone.RegenPerTick, drone.MaxEnergy); } } } ``` ## Bug report Ops report that a drone which reaches full charge on tick N is not released from repair until tick N+1 - it shows 100% energy but the dispatcher still treats it as unavailable for one extra tick, which cascades into scheduling delays across the fleet. ## Your task Fix `TickAll` so a drone that reaches `MaxEnergy` on a given tick is marked complete on that same tick. The completion condition (`Energy >= MaxEnergy`) is correct as written - it is the ORDER of operations within the loop that is wrong. Do not change the public API of `Drone`, `RepairQueue`, or the signature of `TickAll`. Make the smallest change that fixes the bug. Reply with ONLY the corrected `FleetCoordinator.cs` file in one C# code block.