Distribute demand units of traffic across regions [{"name", "healthy", "latency_ms", "capacity"}]:
headroom percent of each region's capacity free (usable = floor(capacity × (100 − headroom) / 100))."degraded": true.Return {"allocation": {region: units} (only regions with traffic), "unserved": n, "degraded": bool}.
Implement allocate. Input: regions: list[dict], demand: int, headroom: int. Returns: dict.
Usable capacity is 80 + 160 = 240, so the last 10 units come from headroom, lowest latency first (eu-west-1).
def allocate(regions, demand, headroom):
healthy = [r for r in regions if r["healthy"]]
share = demand // max(len(healthy), 1)
return {"allocation": {r["name"]: share for r in healthy}, "unserved": 0, "degraded": False}
Run executes the public tests. Submit grades against public and hidden tests.
Distribute demand units of traffic across regions [{"name", "healthy", "latency_ms", "capacity"}]:
headroom percent of each region's capacity free (usable = floor(capacity × (100 − headroom) / 100))."degraded": true.Return {"allocation": {region: units} (only regions with traffic), "unserved": n, "degraded": bool}.
Implement allocate. Input: regions: list[dict], demand: int, headroom: int. Returns: dict.
Usable capacity is 80 + 160 = 240, so the last 10 units come from headroom, lowest latency first (eu-west-1).
def allocate(regions, demand, headroom):
healthy = [r for r in regions if r["healthy"]]
share = demand // max(len(healthy), 1)
return {"allocation": {r["name"]: share for r in healthy}, "unserved": 0, "degraded": False}
Run executes the public tests. Submit grades against public and hidden tests.