Загрузка данных


from itertools import permutations
cnt = 0
words = []
alf = sorted('ПРАВИЛО')
for kword in permutations(alf, r=5):
    word = set(kword)
    if word not in words:
        if 'АИ' not in (''.join(kword)) \
           and 'АО' not in \
           ''.join(kword) and \
           'ИО' not in ''.join(kword):
            words.append(word)
            cnt += 1
            if cnt == 18:
                word18 = ''.join(kword)
print(cnt, word18)