Find the request where a shadow budget runs out

Agent buildHard40 min

Your task

Your new agent version runs in shadow mode. A copy of some live requests goes to it, and its replies are compared with the current version's. Users never see them. Several samplers pick which requests to copy. Each one takes every p-th request. You have paid for k shadow runs, and you want to know when they run out.

Write budget_end(samplers, k) that returns the number of the request that uses the last paid run.

Input and output:

  • samplers: 1 to 12 different whole numbers from 2 to 1,000. A sampler with value p picks requests p, 2p, 3p and so on.
  • k: a whole number from 1 to 100,000,000,000.
  • Return a whole number: the number of the k-th request that at least one sampler picks.

Rules:

  • Requests are numbered 1, 2, 3 and so on, with no gaps and no end.
  • A request picked by several samplers is copied once and uses one run.

Examples

budget_end(samplers: list[int], k: int) -> int
Example 1
Inputbudget_end([3, 5], 6)
Output12
Example 2
Inputbudget_end([4, 6, 10], 5)
Output12
Example 3
Inputbudget_end([7], 100)
Output700