Skip to content

Instantly share code, notes, and snippets.

@computingfreak
Created March 16, 2019 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save computingfreak/9dac92830ef3618cd4853f855af6cd83 to your computer and use it in GitHub Desktop.
Save computingfreak/9dac92830ef3618cd4853f855af6cd83 to your computer and use it in GitHub Desktop.
from itertools import permutations,combinations
string = raw_input()
text=string.split(" ")[0]
num=int(string.split(" ")[1])
rc = list()
words=list(text)
words.sort()
for j in range(1,num+1):
pc = list(combinations(words,j))
#pc = list(permutations(list(text),num))
qc = list()
for e in pc:
qc.append(''.join(map(str,e)))
#qc.sort()
for k in qc:
rc.append(k)
for f in rc:
print(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment