fork download
  1. import sys
  2.  
  3. def generate_subsets(strr, n):
  4.  
  5. #f = open("submultimi.out", "w")
  6.  
  7. total = pow(2, n)
  8.  
  9. for i in range(1, total):
  10.  
  11. for x in range(0, n):
  12.  
  13. if i & (1<<x) != 0:
  14.  
  15. #sys.stdout.write(str(x+1) + " ")
  16. sys.stdout.write(strr[x] + " ")
  17. #f.write(str(x+1) + " ")
  18.  
  19. #f.write("\n")
  20. print ""
  21.  
  22.  
  23. def main():
  24.  
  25. str = "abc"
  26. #f = open("submultimi.in", "r")
  27. #n = int(f.readline())
  28. n = len( str )
  29. #n = 4
  30.  
  31. generate_subsets(str, n)
  32. main()
Success #stdin #stdout 0.01s 7172KB
stdin
Standard input is empty
stdout
a 
b 
a b 
c 
a c 
b c 
a b c