304 North Cardinal St.
Dorchester Center, MA 02124
You are given a string S.
Your task is to print all possible combinations, up to size k, of the string in lexicographic sorted order.
A single line containing the string S and integer value k separated by a space.
Print the different combinations of string S on separate lines.
A C H K AC AH AK CH CK HK
from itertools import permutations S,k = raw_input().split() k = int(k) print '\n'.join(sorted(''.join(p) for p in permutations(S,k)))
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import permutations s,n = input().split() print(*[''.join(i) for i in permutations(sorted(s),int(n))],sep='\n')
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import permutations string_number = raw_input().split() string = string_number number = map(int, string_number) for elem in sorted(list(permutations(string, number))): n = len(elem) elem_print = "" for i in range(0, n): elem_print+=elem[i] print elem_print
# Enter your code here. Read input from STDIN. Print output to STDOUT import itertools ll, n = input().split() for i in itertools.permutations(sorted(ll),int(n)): print("".join(i))
In our experience, we suggest you solve this itertools.permutations() Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
I hope this itertools.permutations() Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning Programming in a business context; there are no prerequisites.
More Hacker Rank Problem & Solutions >>