Код #1. Стандартный перебор. Время работы - 0.6 секунды.
from itertools import permutations
k = 0
for i in set(permutations('АССЕМБЛЕР', r=9)):
s = ''.join(i)
sumpos = 0
for j in range(len(s)):
if s[j]=='А' or s[j]=='Е':
sumpos+=(j+1) #порядковый номер на единицу больше индекса
if sumpos==9:
k+=1
print(k)
Код #2. Перебор конфигураций. Время работы - 0.015 секунды.
from itertools import product
k = 0
for i in product('012', repeat=9):
s = ''.join(i)
if s.count('0')==1 and s.count('2')==2 and \
sum(j for j in range(len(s)) if s[j]=='0' or s[j]=='2')+3==9:
k+=6*5*4*3*2/2 #в каждой конфигурации 1 * 1 * 1 * 6!/2! вариантов
print(k)