r*******n 发帖数: 3020 | 1 Input: list
Output: print result
How to use:
For example:
combination([1,2,3,4])
def combination(a):
result = [[]]
for i in a:
temp=copy.deepcopy(result)
for each in temp:
each.append(i)
result.extend(temp)
print '\n'.join([str(each) for each in result]) | s*********l 发帖数: 103 | 2 http://bitbucket.org/spellscroll/spellscrolls/src/tip/combinatorics.py
【在 r*******n 的大作中提到】 : Input: list : Output: print result : How to use: : For example: : combination([1,2,3,4]) : def combination(a): : result = [[]] : for i in a: : temp=copy.deepcopy(result) : for each in temp:
|
|