THINK FIRST·CODE LATER

← All labs

The review bottleneck: simulate agent PRs vs. human review

Problem

Agents can open pull requests faster than humans can review them. Simulate the review queue day by day.

Input: first line days reviewCapacity wipLimit. Second line: days integers — the number of PRs agents want to open on each day.

Each day, in this order:

  1. Arrivals: if wipLimit is 0 (no limit), all wanted PRs are added to the queue; otherwise agents may add PRs only while the queue is below wipLimit (so at most wipLimit - queue are added; the others are not created that day).
  2. Reviews: humans review up to reviewCapacity PRs from the front of the queue (oldest first). Each reviewed PR's waiting time is today - arrivalDay (0 if reviewed on the day it arrived).

Print for each day Day d: +added (wanted w), reviewed r, queue q. At the end print:

Reviewed: R, Still waiting: S
Average wait: x.xx days
Max queue: M

(average over reviewed PRs, two decimals; 0.00 if none; the maximum queue is the largest queue size measured right after the arrivals of a day).

Input:

5 10 0
30 30 30 5 5

Output:

Day 1: +30 (wanted 30), reviewed 10, queue 20
Day 2: +30 (wanted 30), reviewed 10, queue 40
Day 3: +30 (wanted 30), reviewed 10, queue 60
Day 4: +5 (wanted 5), reviewed 10, queue 55
Day 5: +5 (wanted 5), reviewed 10, queue 50
Reviewed: 50, Still waiting: 50
Average wait: 1.60 days
Max queue: 70

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.