Write run_agent: the meal allowance in force on the trip date

Agent buildHard50 min

Policy lookups go wrong quietly: the newest number is not always the one that applied.

Your task

Write run_agent. It finds the daily meal allowance that applied to a trip.

  • search(query) returns the ids of documents containing that text, shortest first
  • fetch(doc_id) returns that document, or None when the id does not exist
  • the trip record gives the city and the start date; allowance cards give a city's rate and the date it took effect
  • the card that applies is approved, took effect on or before the start date, and has the latest such date; drafts and withdrawn cards never apply
  • answer in whole euros, such as 48, or not found when the trip, or a card that applies, is missing
  • each scenario carries a token budget, and some are too small to read every document that mentions the city

At submit the suite runs your agent against trips and policies you have not seen.