• + 0 comments

    python 3

    def birthday(s, d, m): chococalate = 0 total = sum(s[:m])

    if total == d:
        chococalate += 1
    
    for i in range(len(s)-m):
        total = total - s[i] + s[i+m]
    
        if total == d:
            chococalate +=1
    
    return chococalate