Advertisement
here2share

# permutations_fullscale.py

Nov 18th, 2019
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # permutations_fullscale.py
  2.  
  3. def permutations(l, n, str_a=''):
  4.     if len(str_a) == n:
  5.         print str_a
  6.     else:
  7.         for c in l:
  8.             permutations(l, n, str_a+c)
  9. def permutations_fullscale(data):
  10.     for z in range(1,len(data)+1):
  11.         permutations(data, z)
  12.  
  13. zzz = permutations_fullscale("ABC")
  14.  
  15. '''
  16. output...
  17.  
  18. A
  19. B
  20. C
  21. AA
  22. AB
  23. AC
  24. BA
  25. BB
  26. BC
  27. CA
  28. CB
  29. CC
  30. AAA
  31. AAB
  32. AAC
  33. ABA
  34. ABB
  35. ABC
  36. ACA
  37. ACB
  38. ACC
  39. BAA
  40. BAB
  41. BAC
  42. BBA
  43. BBB
  44. BBC
  45. BCA
  46. BCB
  47. BCC
  48. CAA
  49. CAB
  50. CAC
  51. CBA
  52. CBB
  53. CBC
  54. CCA
  55. CCB
  56. CCC
  57. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement