Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-240

Special Token Budget

Problem

Compute how many content tokens fit after special tokens and a generation reserve are subtracted from the context limit.

Return max(0, context_limit - n_special - reserve).

Hint

Clamp the result at zero so an overfull prompt reports no budget.

Test cases

case 1
in: [512,3,64]
expected: 445
case 2
in: [128,200,0]
expected: 0
case 3
in: [0,0,0]
expected: 0
case 4
in: [2048,2,512]
expected: 1534
Starter codePython
def special_token_budget(context_limit, n_special, reserve):
    # Your code here
    pass

4 test cases · run your code against them in the editor