Paste Search Dynamic
Recent pastes
itertools
  1. import itertools
  2. n,m  = map(int, input().split(','))
  3. new = ""
  4. final = ""
  5. for i in range(n):
  6.         # lst = list(map(int,input().split(',')))[:m]
  7.         lst = list(input().split(','))[:m]
  8.         # for j in lst:
  9.         #       new.append(j)
  10.         new = ''.join(lst)
  11. print(new)
  12. p = list(itertools.permutations(new))
  13. res = list(max(p))
  14. for i in res:
  15.         final = final + ",".join(str(i))
  16. print(final)
Parsed in 0.004 seconds