itertools.combinations()

Sort by

recency

|

885 Discussions

|

  • + 0 comments

    from itertools import combinations

    st = input().split()

    s = st[0]

    k = int(st[1])

    sorted_string = sorted(s)

    for i in range(1, k+1):

    for combo in combinations(sorted_string, i):

    print(''.join(combo))
    
  • + 0 comments
    from itertools import combinations as com
    l,p = input().split()
    l = sorted(l)
    for i in range(int(p)):
        b = list(com(l,(int(i) + 1)))
        for k in b:
            print(''.join(k))
    
  • + 0 comments

    from itertools import combinations

    a, b = input().split()

    a =sorted(str(a))

    A = []

    x = int(b) for i in range(1, int(b)+1): A.append(list(combinations(a, i))) x += i

    for j in range(int(b)): for i in range(len(A[j])): print(''.join(A[j][i]))

  • + 0 comments

    from itertools import combinations

    def combine(s, k): for i in range(1, k+1): var = list(combinations(s, i)) [print(''.join(x)) for x in var]

    s, k = input().split() s = list(s.upper()) # s determined as list s.sort() combine(s, int(k))

  • + 0 comments
    from itertools import combinations
    S, k = input().split()
    S = sorted(S)
    k = int(k)
    for x in range(1, k + 1):
        for y in combinations(S, x):
            print(''.join(y))