Token Budget Truncation
Return passage texts in order while the cumulative token count stays within budget. Skip a passage that does not fit and continue checking later passages.
Examples
EXAMPLE WALKTHROUGHskip oversized
A guided view of the published example, not a trace of your code.
INPUT
[[["a",4],["b",5],["c",2]],6]TASKfit_context()
EXPECTED OUTPUT
["a","c"]Start with the input values shown in this example.
Example 1 of 2
Input: passages = [["a",4],["b",5],["c",2]], budget = 6
Output: ["a","c"]
Explanation: skip oversized
Input: passages = [["a",2],["b",3]], budget = 5
Output: ["a","b"]
Explanation: exact budget
Hint 1
A later smaller passage may still fit.