Sending notifications in batches

Write code · Challenge · §8.3 Guessing the answer and checking it

subs holds the subscriber count of each person who uploaded a new post, in the order they uploaded. Each of an uploader's subscribers gets one new-post notification, and the notification server sends one batch of notifications once a minute. If the batch limit is set to m, each batch keeps adding the notifications for the next person in the order of subs while its total stays at most m; the first person who does not fit starts the next batch. The notifications for one uploader (as many as that person's subscribers) are never split; they all go in the same batch.

Complete the function solution, which returns the smallest m with which all notifications are sent within d minutes (in at most d batches).

Function

solution(subs, d)

Constraints

Examples

subsdresult
[25, 50, 25, 20, 25, 40]375
[20, 60, 60, 45, 20]2125

Starter code

def solution(subs, d):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.