Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # paulogp
- def lista_combinacoes(n, k, L):
- '''
- Retorna todas as combinacoes possiveis a serem realizadas numa lista
- n colunas de L
- k colunas a filtrar de L
- L = [] inicialmente
- PS: Funcao recursiva
- '''
- if k != 0:
- for x in range(0, n):
- if (x not in L):
- if len(L) == 0:
- lista_combinacoes(n, k-1, L+[x])
- elif (x > L[len(L)-1]):
- lista_combinacoes(n, k-1, L+[x])
- else:
- print L
- # Exemplo
- lista_combinacoes(6, 2, [])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement