All problems
Continuous Batching Rounds
Problem
Count scheduling rounds for continuous batching. Requests are packed greedily in order into rounds whose total token count must not exceed max_tokens_per_batch; a request that does not fit starts a new round.
The signature is continuous_batching_rounds(request_tokens, max_tokens_per_batch). Return the number of rounds.
Hint
Continuous batching fills each round with as many queued requests as fit.
Test cases
case 1
in: [[100,200,300],400]
expected: 2
case 2
in: [[400,400],400]
expected: 2
case 3
in: [[100,100],400]
expected: 1
case 4
in: [[500],400]
expected: 1
case 5
in: [[],400]
expected: 0
Starter codePython
def continuous_batching_rounds(request_tokens, max_tokens_per_batch):
# Your code here
pass5 test cases · run your code against them in the editor