1x = [2, 1.2, 1, 0.5]
2max_val = 5
3
4def find_next(state, idx, check=False):
5 if(idx == len(x)):
6 return print_it(state, check)
7 if(sum(state) + x[idx] > max_val):
8 find_next(state, idx + 1, True)
9 else:
10 find_next(state + [x[idx]], idx)
11 find_next(state, idx + 1)
12
13def print_it(state, check):
14 if check:
15 print("")
16 print(sum(state),state)
17 return
18
19
20find_next([],0)
21
22