• + 0 comments

    python3

    def workbook(n, k, arr):
        # Write your code here
      
        ch = []
        
        # step 1: create chapters
        for i in arr:
            c = list(range(1,i+1))
            for j in range(1,i//k+1):
                ch.append(c[:k])
                c = c[k:] # this might add some empty chapters
            ch.append(c)
            
        ch = list(filter(lambda i: len(i) != 0, ch)) # remove empty chapters
    
        #step 2: find special problems
        count = 0
        for i,j in enumerate(ch):
            if i + 1 in j:
                count +=1
            
        return count