Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. from itertools import permutations,combinations
  2.  
  3. string = raw_input()
  4. text=string.split(" ")[0]
  5. num=int(string.split(" ")[1])
  6. rc = list()
  7. words=list(text)
  8. words.sort()
  9. for j in range(1,num+1):
  10. pc = list(combinations(words,j))
  11. #pc = list(permutations(list(text),num))
  12. qc = list()
  13. for e in pc:
  14. qc.append(''.join(map(str,e)))
  15. #qc.sort()
  16. for k in qc:
  17. rc.append(k)
  18. for f in rc:
  19. print(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement