I completed a coding challenge recently in which my function was to be given two parameters: N, the number of counters to be used (numbered 1 through N) - and A, an array of integers. Iterating through the array A, when the index of a counter occurs, that counter is incremented by 1. When an index of N+1 occurs, all of the counters are reset to the maximum counter at that point.
def solution(N, A):
li = [0] * N
#print('A is %s' % A)
#print('N is %s' % N)
max_val = 0
for i in A:
i = i-1
#print('i is %s' % i)
#print('li is %s' % li)
if i == N:
#print(' in if')
li = [max_val] * N
else:
#print(' in else')
li[i] = li[i] + 1
if li[i] > max_val:
max_val = li[i]
return li
[Using Python 3.6]
(See related question.)