• + 0 comments

    But Solution is almost correct for all but only two, anyone can recode my code

    def solve(a):
        pl = [1]
        tot = sum(a)
        i = 1
        mid = tot // i
        while mid > 1:
            if tot % mid == 0:
                pl.append(mid)
            i += 1
            while mid == tot // i:
                i += 1
            mid = tot // i
        pl.sort()
        ml = []
        print(pl)
        for i in pl:
            tot = 0
            for _ in a:
                tot += _
                if tot == i:
                    tot = 0
                if tot > i:
                    break
            else:
                ml.append(i)
        return ml