Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # nth_combos.py
- from itertools import combinations
- min_length = 3
- max_length = 5
- res = {i: ["".join(li) for li in combinations('abcdefg', i)] for i in range(min_length, max_length + 1)}
- print res
- '''
- {3: ['abc', 'abd', 'abe', 'abf', 'abg', 'acd', 'ace', 'acf', 'acg', 'ade', 'adf', 'adg', 'aef', 'aeg', 'afg', 'bcd', 'bce', 'bcf', 'bcg', 'bde', 'bdf', 'bdg', 'bef', 'beg', 'bfg', 'cde', 'cdf', 'cdg', 'cef', 'ceg', 'cfg', 'def', 'deg', 'dfg', 'efg'], 4: ['abcd', 'abce', 'abcf', 'abcg', 'abde', 'abdf', 'abdg', 'abef', 'abeg', 'abfg', 'acde', 'acdf', 'acdg', 'acef', 'aceg', 'acfg', 'adef', 'adeg', 'adfg', 'aefg', 'bcde', 'bcdf', 'bcdg', 'bcef', 'bceg', 'bcfg', 'bdef', 'bdeg', 'bdfg', 'befg', 'cdef', 'cdeg', 'cdfg', 'cefg', 'defg'], 5: ['abcde', 'abcdf', 'abcdg', 'abcef', 'abceg', 'abcfg', 'abdef', 'abdeg', 'abdfg', 'abefg', 'acdef', 'acdeg', 'acdfg', 'acefg', 'adefg', 'bcdef', 'bcdeg', 'bcdfg', 'bcefg', 'bdefg', 'cdefg']}
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement