We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def test(input_,b):
e = sorted(list(input_))
for i in range(1,b+1):
c = list(combinations(e,i))
for i in c:
print(''.join(i))
if name == "main":
input_,b = input().split()
b = int(b)
test(input_,b)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.combinations()
You are viewing a single comment's thread. Return to all comments →
from itertools import combinations
def test(input_,b): e = sorted(list(input_)) for i in range(1,b+1): c = list(combinations(e,i)) for i in c: print(''.join(i)) if name == "main": input_,b = input().split() b = int(b) test(input_,b)