# Python3 program to print all the
# expressions for the input value
# Function to print all the
# expressions using the number
def PrintRecursive(str, arr, i, n, res, j, len, ln):
# Termination condition
if(j==len):
print(res)
return
# Even position will contain
# the numbers
if(j%2==0):
res[j] = arr[i]
# Recursive call
PrintRecursive(str,arr,i+1,n,res,j+1,len,ln)
else:
# Add a symbol from string in
# odd position.
for k in range(0,ln):
res[j] = str[k]
PrintRecursive(str,arr,i,n,res,j+1,len,ln)
def PrintExpressions(n):
# Character array containing
# expressions
str = [ '+','-','/','*' ]
ln = len(str)
a = []
for i in range(0,n):
a.append(0)
a[i] = i + 1
res = []
for i in range(0,(2 * n)-1):
res.append('')
PrintRecursive(str, a, 0, n, res, 0, 2*n-1, ln)
return
# Driver code
n = 2
PrintExpressions(n)
# This code is contributed by akashish__