LINUX.ORG.RU

История изменений

Исправление question4, (текущая версия) :

с каким нить ключем слов в словарь

Да, очень хорошо работает, особенно если брать слова длиннее 4 букв.

import py7zr
wordlist = py7zr.SevenZipFile('russian-wordlist-inflections-1251.txt.7z').read()['russian-wordlist-inflections-1251.txt'].read().decode('cp1251').upper().split()

def wl_score(text):
    '''Суммарная длина найденных слов длиннее 4 букв.'''
    return sum( len(w) for w in wordlist if (len(w) >= 4) and (w in text) )

for razr in range(1,13):
    shifts = [0] * razr
    for place in range(razr):
        probs = letter_frequencies(message[place::razr])
        match = [ shiftmatch(etalon, probs, s)*100 for s in range(10) ]
        mm = min(match)
        shifts[place] = match.index(mm)
        print(razr, place, shifts[place], mm, sep = '\t')
    t = ''.join(alph32[(rln32(l) - shifts[p % razr]) % 32] for p,l in enumerate(message));
    print(wl_score(t), t)

В шифрованном тексте находит 1 слово — «РУДЕНКО» :)

Исходная версия question4, :

с каким нить ключем слов в словарь

Да, очень хорошо работает, особенно если брать слова длиннее 4 букв.

import py7zr
wordlist = py7zr.SevenZipFile('russian-wordlist-inflections-1251.txt.7z').read()['russian-wordlist-inflections-1251.txt'].read().decode('cp1251').upper().split()

def wl_score(text): return sum( len(w) for w in wordlist if (len(w) >= 4) and (w in text) )

for razr in range(1,13):
    shifts = [0] * razr
    for place in range(razr):
        probs = letter_frequencies(message[place::razr])
        match = [ shiftmatch(etalon, probs, s)*100 for s in range(10) ]
        mm = min(match)
        shifts[place] = match.index(mm)
        print(razr, place, shifts[place], mm, sep = '\t')
    t = ''.join(alph32[(rln32(l) - shifts[p % razr]) % 32] for p,l in enumerate(message));
    print(wl_score(t), t)

В шифрованном тексте находит 1 слово — «РУДЕНКО» :)