Код ниже сначала вызывает zip(text.upper(), text.lower()) и затем применяет itertools.product к *zip(text.upper(), text.lower()).
(.env) boris@boris-All-Series:~/VOTING$ cat allCombinatios.py
from itertools import product
text = 'Yandex'
# convert to list
result = list(map(''.join, product(*zip(text.upper(), text.lower()))))
print(result)
print(len(result))
print('\n')
# convert to tuple
result1 = tuple(map(''.join, product(*zip(text.upper(), text.lower()))))
print(result1)
print(len(result1))
(.env) boris@boris-All-Series:~/VOTING$ python3 allCombinatios.py
['YANDEX', 'YANDEx', 'YANDeX', 'YANDex', 'YANdEX', 'YANdEx', 'YANdeX', 'YANdex', 'YAnDEX', 'YAnDEx', 'YAnDeX', 'YAnDex', 'YAndEX', 'YAndEx', 'YAndeX', 'YAndex', 'YaNDEX', 'YaNDEx', 'YaNDeX', 'YaNDex', 'YaNdEX', 'YaNdEx', 'YaNdeX', 'YaNdex', 'YanDEX', 'YanDEx', 'YanDeX', 'YanDex', 'YandEX', 'YandEx', 'YandeX', 'Yandex', 'yANDEX', 'yANDEx', 'yANDeX', 'yANDex', 'yANdEX', 'yANdEx', 'yANdeX', 'yANdex', 'yAnDEX', 'yAnDEx', 'yAnDeX', 'yAnDex', 'yAndEX', 'yAndEx', 'yAndeX', 'yAndex', 'yaNDEX', 'yaNDEx', 'yaNDeX', 'yaNDex', 'yaNdEX', 'yaNdEx', 'yaNdeX', 'yaNdex', 'yanDEX', 'yanDEx', 'yanDeX', 'yanDex', 'yandEX', 'yandEx', 'yandeX', 'yandex']
64 = 2^6 в слове Yandex шесть букв и для каждой два регистра.
('YANDEX', 'YANDEx', 'YANDeX', 'YANDex', 'YANdEX', 'YANdEx', 'YANdeX', 'YANdex', 'YAnDEX', 'YAnDEx', 'YAnDeX', 'YAnDex', 'YAndEX', 'YAndEx', 'YAndeX', 'YAndex', 'YaNDEX', 'YaNDEx', 'YaNDeX', 'YaNDex', 'YaNdEX', 'YaNdEx', 'YaNdeX', 'YaNdex', 'YanDEX', 'YanDEx', 'YanDeX', 'YanDex', 'YandEX', 'YandEx', 'YandeX', 'Yandex', 'yANDEX', 'yANDEx', 'yANDeX', 'yANDex', 'yANdEX', 'yANdEx', 'yANdeX', 'yANdex', 'yAnDEX', 'yAnDEx', 'yAnDeX', 'yAnDex', 'yAndEX', 'yAndEx', 'yAndeX', 'yAndex', 'yaNDEX', 'yaNDEx', 'yaNDeX', 'yaNDex', 'yaNdEX', 'yaNdEx', 'yaNdeX', 'yaNdex', 'yanDEX', 'yanDEx', 'yanDeX', 'yanDex', 'yandEX', 'yandEx', 'yandeX', 'yandex')
64
No comments:
Post a Comment