Skip to content

Instantly share code, notes, and snippets.

@rjshekar90
Created March 7, 2017 23:29
Show Gist options
  • Save rjshekar90/8ed5203632caa7eed59c2d1d8c500189 to your computer and use it in GitHub Desktop.
Save rjshekar90/8ed5203632caa7eed59c2d1d8c500189 to your computer and use it in GitHub Desktop.
from itertools import combinations_with_replacement
S,K = raw_input().split()
print "\n".join("".join(i) for i in list(combinations_with_replacement(sorted(S),int(K))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment