# Possible Combinations | coding ninjas

Possible Combinations

#### Input Format:

``````First line contains N - (Integer)
Second line contains N spaced integers which are player Id of players. Note that, all the N integers are given in sorted order.
``````

#### Output Format:

``````Print the space separated combinations in N lines
``````

#### Constraints

``````12<= N <= 20
1 <= Ai <=1000
``````

#### Sample Input :

``````13
1 2 3 4 5 6 7 8 9 10 11 12 13
``````

#### Sample Output :

``````1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 13
1 2 3 4 5 6 7 8 9 10 12 13
1 2 3 4 5 6 7 8 9 11 12 13
1 2 3 4 5 6 7 8 10 11 12 13
1 2 3 4 5 6 7 9 10 11 12 13
1 2 3 4 5 6 8 9 10 11 12 13
1 2 3 4 5 7 8 9 10 11 12 13
1 2 3 4 6 7 8 9 10 11 12 13
1 2 3 5 6 7 8 9 10 11 12 13
1 2 4 5 6 7 8 9 10 11 12 13
1 3 4 5 6 7 8 9 10 11 12 13
2 3 4 5 6 7 8 9 10 11 12 13``````

Code(Python):-

def printcmb(arr,n,r):
data=[0]*r
combinations(arr,data,0,n-1,0,r)
def  combinations(arr,data,start,end,index,r):
if index==r:
for j in range(r):
print(data[j],end=" ")
print()
return ;
i=start
while (i<=end and end-i+1>=r-index):
data[index]=arr[i]
combinations(arr,data,i+1,end,index+1,r)
i+=1

n=int(input())
l=list(map(int,input().split()))
printcmb(l,n,12)

### Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-
iMocha coding Questions:-
Tech Mahindra coding questions:-
Unthinkable Solutions coding questions:-