Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # permutations_fullscale.py
- def permutations(l, n, str_a=''):
- if len(str_a) == n:
- print str_a
- else:
- for c in l:
- permutations(l, n, str_a+c)
- def permutations_fullscale(data):
- for z in range(1,len(data)+1):
- permutations(data, z)
- zzz = permutations_fullscale("ABC")
- '''
- output...
- A
- B
- C
- AA
- AB
- AC
- BA
- BB
- BC
- CA
- CB
- CC
- AAA
- AAB
- AAC
- ABA
- ABB
- ABC
- ACA
- ACB
- ACC
- BAA
- BAB
- BAC
- BBA
- BBB
- BBC
- BCA
- BCB
- BCC
- CAA
- CAB
- CAC
- CBA
- CBB
- CBC
- CCA
- CCB
- CCC
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement