mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Delete combinations.py
This commit is contained in:
parent
9c4f52e7bc
commit
20c3036b4d
@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__author__ = "bt3"
|
||||
|
||||
|
||||
def combinations(s):
|
||||
'''
|
||||
>>> combinations('abc')
|
||||
['abc', 'acb', 'bac', 'bca', 'cab', 'cba']
|
||||
>>> combinations('')
|
||||
''
|
||||
'''
|
||||
if len(s) < 2:
|
||||
return s
|
||||
res = []
|
||||
for i, c in enumerate(s):
|
||||
res.append(c)
|
||||
for j in combinations(s[:i] + s[i+1:]):
|
||||
res.append(c + j)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
Loading…
x
Reference in New Issue
Block a user