Q1
program to make all splits of a given no.

def compute(prefix,m):
if m==0:
refurn(prefix)
for i in range(m):
compute(prefix+[i],m-i)Q2
Program to make all legal combinations of n balanced brackets
n=int(input())
counter=0
def brackets(n,text="",opened=0,closed=0):
if closed==n:
print(text)
return
if opened>closed:
brackets(n,test+")",opened,closed+1)
##here the key thing to note is that we can always open a bracket
if opened < n and opened - closed < D:
beackets(n,test+"(",opened+1,closed)
brackets(n)