Светлана составляет коды из букв своего имени. Код должен состоять из
Решение. Заметим, что алфавит состоит из
Пусть одна
Пусть одна
Заметим, что передвигая первую
Таким образом, Светлана может составить
Ответ: 15120.
Приведём другое решение на языке Python.
import itertools
alphabet = "СВЕТЛАНА"
ar = itertools.permutations(alphabet, 8) #Размещение
arl = []
for e in ar:
arl.append(list(e))
a = set()
for e in arl:
flag = True
s = ""
for i in range(len(e)-1):
s += e[i]
if e[i] == e[i + 1]:
flag = False
if flag:
a.add(s)
print(len(a))
Приведём другое решение на языке Python.
q = 0
sett = set()
for i1 in 'СВЕТЛАНА':
for i2 in 'СВЕТЛАНА':
for i3 in 'СВЕТЛАНА':
for i4 in 'СВЕТЛАНА':
for i5 in 'СВЕТЛАНА':
for i6 in 'СВЕТЛАНА':
for i7 in 'СВЕТЛАНА':
for i8 in 'СВЕТЛАНА':
a = i1+i2+i3+i4+i5+i6+i7+i8
if a.count('А') == 2 and a.count('С') == 1 and a.count('В') == 1 and a.count('Е') ==1 and a.count('Т')==1 and a.count('Л') == 1 and a.count('Н') == 1:
if i1 != i2 and i2 != i3 and i3 != i4 and i4 != i5 and i5 != i6 and i6 != i7 and i7 != i8 and (not(a in sett)):
sett.add(a)
q += 1
print(q)
Приведём решение Степана Козлова на языке Python.
from itertools import *
k = 0
d = set()
for i in product('СВЕТЛАНА', repeat = 8):
s = ''.join(i)
if len(set(s)) == 7 and 'АА' not in s and s.count('А') == 2:
d.add(s)
print(len(d))
Приведём решение Сергея Донец на языке PascalABC.NET.
begin
'СВЕТЛАНА'.Permutations(8).Distinct
.Count(s->s.Pairwise.All(\(pr,cr)->pr<>cr))
.Print;//15120
end.
PDF-версии: 