fork download
  1. def fn4() -> None:
  2.  
  3. def solve( n ) -> None:
  4.  
  5. k = 2 ** n
  6.  
  7. for i in range(1, k):
  8.  
  9. for j in range(0, n):
  10.  
  11. if (1<<j)&i:
  12.  
  13. print(j+1, end = " ")
  14.  
  15. print()
  16.  
  17. n = 3
  18.  
  19. solve( n )
  20.  
  21. fn4()
  22.  
Success #stdin #stdout 0.03s 9700KB
stdin
Standard input is empty
stdout
1 
2 
1 2 
3 
1 3 
2 3 
1 2 3