I have 2 inputs as:
p = 7
s = [2 2 8 1 3]
I know how to get basic list subsets by itertool.combinations
but want I want is contiguous sublists with each sublist with sum of their elements being less than p
.
So output will be:
[2],[2,2],[2],[1],[1,3],[3]
Here I got 6 such sublists where for each sublist, sum(sublist) < p
.