# Авторские учебные примеры Академии С. Python 3. from itertools import product count = 0 for letters in product("АБВ", repeat=4): word = "".join(letters) if word.count("А") == 1 and word[0] != "Б": count += 1 print(count) # 20 from itertools import permutations print(sum(1 for _ in permutations("АБВГ", 3))) # 24 unique_words = {"".join(p) for p in permutations("ТОПОТ")} print(len(unique_words)) # 30 from itertools import product for number, letters in enumerate(product("АБВ", repeat=3), start=1): word = "".join(letters) if word == "БАВ": print(number) # 12 break from itertools import product count = 0 for digits in product("012345", repeat=3): word = "".join(digits) if word[0] != "0" and len(set(word)) == 3 and int(word[-1]) % 2 == 0: count += 1 print(count) # 52