You are viewing a single comment's thread. Return to all comments →
Im not sure of this solution. This will not be working with this input:
1 2 1 3 3
The output should be 2 but will be 3 because it will count last digit of the series 3. This solution does not consider what if solution will be shorter than a month digit.
Sure, this will pass all validators but still... :).
return sum(1 for x in range(len(s)) if sum(s[x:x+m]) == d and len(s[x:x+m]) == m )