SHARE
TWEET

Untitled

a guest Feb 27th, 2020 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def print_all_subsets(original_set):
  2.     def _print_subset(arr, original_set):
  3.         res = ''
  4.         for i in xrange(len(arr)):
  5.             if arr[i] == 1:
  6.                 res += str(original_set[i]) + ' '
  7.         print res
  8.  
  9.     def _recursion(depth, arr, original_set):
  10.         if depth == len(arr):
  11.             _print_subset(arr, original_set)
  12.             return
  13.  
  14.         for i in [0, 1]:
  15.             arr[depth] = i
  16.             _recursion(depth + 1, arr, original_set)
  17.  
  18.  
  19.     _recursion(0, [0 for i in range(len(original_set))], original_set)
  20.  
  21.  
  22. arr = ['a', 'b', 'f', 'i', 'w']
  23. print_all_subsets(arr)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top