itertools.combinations_with_replacement()

  • + 2 comments

    Here is Python 3 solution from my HackerrankPractice repository:

    import itertools
    s = input().split()
    string, number = sorted(s[0]), int(s[1])
    print(*list(map(''.join, itertools.combinations_with_replacement(string, number))), sep='\n')
    

    Feel free to ask if you have any questions :)