Advertisement
here2share

# fast_combo_unique.py

Dec 21st, 2021
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # fast_combo_unique.py
  2.  
  3. from itertools import combinations
  4.  
  5. def combine(zeros=3, ones=2):
  6.     for indices in combinations(range(zeros+ones), ones):
  7.         item = ['0'] * (zeros+ones)
  8.         for index in indices:
  9.             item[index] = '1'
  10.         yield ''.join(item[::-1])
  11.  
  12. for z in combine(3, 2):
  13.    print z,
  14.    
  15. '00011 00101 01001 10001 00110 01010 10010 01100 10100 11000'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement