Advertisement
here2share

# permutations.py

Feb 28th, 2021
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. # permutations.py
  2.  
  3. import itertools
  4.  
  5. for p in itertools.permutations([1, 2, 3, 4], 3):
  6.     print(''.join(['abcd'[i-1] for i in p]))
  7. '''
  8. abc
  9. abd
  10. acb
  11. acd
  12. adb
  13. adc
  14. bac
  15. bad
  16. bca
  17. bcd
  18. bda
  19. bdc
  20. cab
  21. cad
  22. cba
  23. cbd
  24. cda
  25. cdb
  26. dab
  27. dac
  28. dba
  29. dbc
  30. dca
  31. dcb
  32. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement