Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # combos_fullscale.py
- def combos(data,n):
- if not n:
- return [[]]
- d=[]
- for i in range(0,len(data)):
- m=data[i]
- remdata=data[i+1:]
- for p in combos(remdata,n-1):
- d.append([m]+p)
- return d
- def combos_fullscale(data):
- d = []
- for z in range(1,len(data)+1):
- d.extend(combos(data, z))
- return d
- print combos_fullscale(["A","B","C"])
- '''
- output...
- [['A'], ['B'], ['C'], ['A', 'B'], ['A', 'C'], ['B', 'C'], ['A', 'B', 'C']]
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement