Advertisement
here2share

# nth_combos.py

May 2nd, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # nth_combos.py
  2.  
  3. from itertools import combinations
  4.  
  5. min_length = 3
  6. max_length = 5
  7.  
  8. res = {i: ["".join(li) for li in combinations('abcdefg', i)] for i in range(min_length, max_length + 1)}
  9.  
  10. print res
  11.  
  12. '''
  13. {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']}
  14. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement