itertools.permutations()

  • + 0 comments
    import sys
    from itertools import permutations
    
    for line in sys.stdin.readlines():
        m, n = line.split()
        
    str = sorted(permutations(m, int(n)))
    for i in str:
        print(''.join(i))