Задания
Версия для печати и копирования в MS Word
Тип 8 № 55625
i

Яро­слав со­став­ля­ет коды из букв, вхо­дя­щих в слово ЯРО­СЛАВ. Код дол­жен со­сто­ять из 5 букв, буквы в коде не долж­ны по­вто­рять­ся, со­глас­ных в коде долж­но быть боль­ше, чем глас­ных, две глас­ные буквы нель­зя ста­вить рядом. Сколь­ко кодов может со­ста­вить Яро­слав?

Спрятать решение

Ре­ше­ние.

При­ведём ре­ше­ние на языке Python.

s = 'ЯРО­СЛАВ'

count = 0

for a in s:

for b in s:

for c in s:

for d in s:

for e in s:

s1 = a + b + c + d + e

if s1.count('Я') <= 1 and s1.count('Р') <= 1 and s1.count('О') <= 1 and \

s1.count('С') <= 1 and s1.count('Л') <= 1 and s1.count('А') <= 1 and \

s1.count('В') <= 1 and \

s1.count('Р') + s1.count('С') + s1.count('Л') + s1.count('В') > s1.count('Я') + s1.count('О') + s1.count('А') and \

s1.count('ЯО') == 0 and s1.count('ЯА') == 0 and s1.count('ОА') == 0 and s1.count('ОЯ') == 0 and s1.count('АЯ') == 0 and s1.count('АО') == 0:

count += 1

print(count)

 

Ответ: 1224.

 

При­ведём ре­ше­ние Масис Да­во­я­на на языке Python.

from itertools import *

counter = 0

for perm in permutations('ЯРО­СЛАВ', 5):

word = ''.join(perm)

if ((word.count('Р') + word.count('С') + word.count('Л') + word.count('В')) > \

(word.count('Я') + word.count('О') + word.count('А'))) and (word.count('ЯО') == 0 and \

word.count('ОЯ') == 0 and word.count('ЯА') == 0 and word.count('АЯ') == 0 and \

word.count('ОА') == 0 and word.count('АО') == 0):

counter += 1

print(counter)

 

При­ведём ре­ше­ние Ильи Ан­дри­а­но­ва на языке Python.

from itertools import permutations

count = 0

for var in permutations('ЯРО­СЛАВ', 5):

slovo = ''.join(var)

sogl = [x for x in slovo if x in 'РСЛВ']

glas = [x for x in slovo if x in 'ЯОА']

if len(sogl) > len(glas):

slovo = slovo.replace('Я', 'А').replace('О', 'А')

if 'АА' not in slovo:

count += 1

print(count)

При­ме­ча­ние 8 и 9 стро­ки про­грам­мы воз­мож­но за­ме­нить на if all(pair not in slovo for pair in 'ЯА АЯ ЯО ОЯ АО ОА'.split()):

 

При­ведём ре­ше­ние Ан­дрея Бру­си­лов­ско­го на языке Python.

from itertools import permutations

 

count = 0

for i in permutations ('ЯРО­СЛАВ',r=5):

s =''.join(i)

s = s.replace('Я','А').replace('О','А')

s = s.replace('Р', 'В').replace('С', 'В').replace('Л', 'В')

if s.count('В')>s.count('А') and not 'АА' in s:

count += 1

print(count)

 

 

При­ведём ре­ше­ние Ми­ха­и­ла Глин­ско­го на языке Python.

al = 'ЯРО­СЛАВ'

k = 0

for b1 in al:

for b2 in al:

for b3 in al:

for b4 in al:

for b5 in al:

s=b1+b2+b3+b4+b5

if len(set(s))==5:

s = s.replace('Я','*').replace('О','*').replace('А','*')

if s.count('*')<3 and s.count('**')==0:

k += 1

print(k)

 

При­ведём ре­ше­ние Юрия Кра­силь­ни­ко­ва на языке Python.

from itertools import permutations

k=0

for p in permutations('ЯРО­СЛАВ',5):

t=''.join([('Г' if c in 'ЯОА' else 'С') for c in p])

if t.count('С')>t.count('Г') and not 'ГГ' in t: k+=1

print(k)


Аналоги к заданию № 55595: 55625 Все