Возможные перестановки данной цифры - PullRequest
0 голосов
/ 06 мая 2020

Это код, чтобы узнать возможные перестановки данного di git ..., есть ли возможность уменьшить код

from itertools import permutations
lst=[int(x) for x in input()] #taking input and split
perm = list(permutations(lst))
for i in range(0,len(perm)):
    perm[i]=int("".join(map(str,perm[i])))#join them and covert to int
print(perm)

Ответы [ 2 ]

2 голосов
/ 06 мая 2020
from itertools import permutations
perms = [''.join(p) for p in permutations(input())]
0 голосов
/ 06 мая 2020
from itertools import permutations
lst=list(map(int,input().split()))
perms1 = [int("".join(map(str,i))) for i in list(permutations(lst))]
print(perms1)
...