itertools.combinations_with_replacement()

Sort by

recency

|

525 Discussions

|

  • + 0 comments
    from itertools import combinations_with_replacement
    s, n = input().split(" ")
    [print(''.join(x)) for x in (combinations_with_replacement(sorted(s),int(n)))]
    
  • + 0 comments
    from itertools import combinations_with_replacement as cwr
    
    S, k = input().split()
    merged = cwr(sorted(S), int(k))
    
    for i in merged:
            print(''.join(i))
    
  • + 0 comments
    from itertools import combinations_with_replacement as c
    
    n = input().split()
    
    string = n[0]
    
    size = int(n[1])
    
    sorted_string = ''.join(sorted(string))
    
    lst = [''.join(comb) for comb in c(sorted_string, size)]
    
    print(*lst, sep ="\n")
    
  • + 0 comments

    from itertools import combinations_with_replacement as c

    n = input().split()

    string = n[0]

    size = int(n[1])

    sorted_string = ''.join(sorted(string))

    lst = [''.join(comb) for comb in c(sorted_string, size)]

    print(*lst, sep ="\n")

  • + 0 comments

    from itertools import combinations_with_replacement s,k=input().split() s=sorted(s) l=list(combinations_with_replacement(s,int(k))) x=list() y="" for i in l: for j in i: y+="".join(j) x.append(y) y="" x.sort() for i in x: print(i)