Сколько слов
В конце может стоять две буквы:
Ответ: 256.
Приведём другое решение на языке Python.
import itertools
alphabet = "ЗИМА"
con = "ЗМ"
vol = "ИА"
ar = itertools.product(alphabet, repeat=5) #Размещение с повторением
arl = []
for i in ar:
arl.append(list(i))
count = 0
for e in arl:
if e[0] in con and e[-1] in vol:
count += 1
print(count)
Приведём другое решение на языке Python.
count = 0
for i1 in 'ЗИМА':
for i2 in 'ЗИМА':
for i3 in 'ЗИМА':
for i4 in 'ЗИМА':
for i5 in 'ЗИМА':
s = i1 + i2 + i3 + i4 + i5
if (s[0] == 'З' or s[0] == 'М') and (s[4] == 'И' or s[4] == 'А'):
count += 1
print(count)
Приведём решение Юрия Лысакова на языке Python.
from itertools import product
count = 0
for i in product('ЗИМА', repeat=5):
s = ''.join(i)
if (s[0] == 'З' or s[0] == 'М') and (s[4] == 'И' or s[4] == 'А'):
count += 1
print(count)
Приведём решение Андрея Тухманова на языке Python.
from itertools import *
words = [''.join(i) for i in product(sorted('ЗИМА'), repeat=5) if (i[0] in 'ЗМ') and (i[-1] in 'ИА')]
print(len(words))
Приведём решение Сергея Донец на языке PascalABC.NET.
begin
'ЗИМА'.Cartesian(5)
.Where(s->s.First in 'ЗМ')
.Where(s->s.Last in 'ИА')
.Count.Print;
end.

