simeonshopov

Combinations

Jun 3rd, 2020
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. #!usr/local/bin/python3.8
  2. # -*- coding: utf-8 -*import
  3.  
  4.  
  5. def permutations(chars, index):
  6.     if index == len(chars):
  7.         print(''.join(chars))
  8.         return
  9.     for i in range(index, len(chars)):
  10.         chars[index], chars[i] = chars[i], chars[index]
  11.         permutations(chars, index + 1)
  12.         chars[index], chars[i] = chars[i], chars[index]
  13.  
  14.  
  15. permutations(list(input()), 0)
Advertisement
Add Comment
Please, Sign In to add comment