xxxxxxxxxx
def arr2(A):
n = len(A)
for i in range(0,n):
for j in range(0,n):
if j != i:
print A[i],A[j]
arr2([1,2,3,4])
xxxxxxxxxx
def arr3(A):
n = len(A)
for i in range(0,n):
for j in range(0,n):
for k in range(0,n):
if k != j and k !=i and i != j:
print A[i],A[j],A[k]
arr3([1,2,3,4])
xxxxxxxxxx
def arr2(A):
L = []
n = len(A)
for i in range(0,n):
for j in range(0,n):
if j != i and not([A[j],A[i]] in L):
print A[i],A[j]
L.append([A[i],A[j]])
arr2([1,2,3,4])
xxxxxxxxxx
def arr3(A):
L = []
n = len(A)
for i in range(0,n):
for j in range(0,n):
for k in range(0,n):
if j != i and j != k and i != k:
if not( [A[i],A[k],A[j]] in L ) and not( [A[j],A[i],A[k]] in L ) and not( [A[j],A[k],A[i]] in L ) and not( [A[k],A[i],A[j]] in L ) and not( [A[k],A[j],A[i]] in L ):
print A[i],A[j],A[k]
L.append([A[i],A[j],A[k]])
arr3([1,2,3,4])
xxxxxxxxxx
def listeParties(L):
R = [[]]
for e in L:
for x in R:
R = R + [x+[e]]
return R
def afficheListe(L):
n = len(L)
for i in range(0,n):
print(L[i])
s = [1,2,3,4]
afficheListe(listeParties(s))
xxxxxxxxxx
def listeParties(L):
R = [[]]
for e in L:
for x in R:
R = R + [x+[e]]
return R
def afficheListe(L):
n = len(L)
M = L
for i in range(0,n-1):
for j in range(i,n):
if len(M[j]) < len(M[i]):
x = M[i]
M[i] = M[j]
M[j] = x
for i in range(0,n):
print(M[i])
s = [1,2,3,4]
afficheListe(listeParties(s))