




from __future__ import annotations




def       SCREAMING_SNAKE_CASE			( __UpperCamelCase    :		str ,  __UpperCamelCase    :		dict[str, str]   )						->							str:
    UpperCAmelCase_				,							UpperCAmelCase_				,							UpperCAmelCase_											=  '''''', '''''', ''''''
    UpperCAmelCase_											=  []

    for character in message_part:
        tmp.append(character_to_number[character]   )

    for each in tmp:
        one += each[0]
        two += each[1]
        three += each[2]

    return one + two + three




def       SCREAMING_SNAKE_CASE			( __UpperCamelCase    :		str ,  __UpperCamelCase    :		dict[str, str]   )						->							tuple[str, str, str]:
    UpperCAmelCase_				,							UpperCAmelCase_											=  '''''', ''''''
    UpperCAmelCase_											=  []

    for character in message_part:
        this_part += character_to_number[character]

    for digit in this_part:
        tmp += digit
        if len(__UpperCamelCase   ) == len(__UpperCamelCase   ):
            result.append(__UpperCamelCase   )
            UpperCAmelCase_											=  ''''''

    return result[0], result[1], result[2]




def       SCREAMING_SNAKE_CASE			( __UpperCamelCase    :		str ,  __UpperCamelCase    :		str   )						->							tuple[str, str, dict[str, str], dict[str, str]]:
    # Validate message and alphabet, set to upper and remove spaces
    UpperCAmelCase_											=  alphabet.replace(''' ''' ,  ''''''   ).upper()
    UpperCAmelCase_											=  message.replace(''' ''' ,  ''''''   ).upper()

    # Check length and characters
    if len(__UpperCamelCase   ) != 27:
        raise KeyError('''Length of alphabet has to be 27.'''   )
    for each in message:
        if each not in alphabet:
            raise ValueError('''Each message character has to be included in alphabet!'''   )

    # Generate dictionares
    UpperCAmelCase_											=  (
        '''111''',
        '''112''',
        '''113''',
        '''121''',
        '''122''',
        '''123''',
        '''131''',
        '''132''',
        '''133''',
        '''211''',
        '''212''',
        '''213''',
        '''221''',
        '''222''',
        '''223''',
        '''231''',
        '''232''',
        '''233''',
        '''311''',
        '''312''',
        '''313''',
        '''321''',
        '''322''',
        '''323''',
        '''331''',
        '''332''',
        '''333''',
    )
    UpperCAmelCase_											=  {}
    UpperCAmelCase_											=  {}
    for letter, number in zip(__UpperCamelCase ,  __UpperCamelCase   ):
        UpperCAmelCase_											=  number
        UpperCAmelCase_											=  letter

    return message, alphabet, character_to_number, number_to_character




def       SCREAMING_SNAKE_CASE			( __UpperCamelCase    :		str ,  __UpperCamelCase    :		str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ." ,  __UpperCamelCase    :		int = 5   )						->							str:
    UpperCAmelCase_				,							UpperCAmelCase_				,							UpperCAmelCase_				,							UpperCAmelCase_											=  __prepare(
        __UpperCamelCase ,  __UpperCamelCase   )
    UpperCAmelCase_				,							UpperCAmelCase_											=  '''''', ''''''

    for i in range(0 ,  len(__UpperCamelCase   ) + 1 ,  __UpperCamelCase   ):
        encrypted_numeric += __encrypt_part(
            message[i : i + period] ,  __UpperCamelCase   )

    for i in range(0 ,  len(__UpperCamelCase   ) ,  3   ):
        encrypted += number_to_character[encrypted_numeric[i : i + 3]]

    return encrypted




def       SCREAMING_SNAKE_CASE			( __UpperCamelCase    :		str ,  __UpperCamelCase    :		str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ." ,  __UpperCamelCase    :		int = 5   )						->							str:
    UpperCAmelCase_				,							UpperCAmelCase_				,							UpperCAmelCase_				,							UpperCAmelCase_											=  __prepare(
        __UpperCamelCase ,  __UpperCamelCase   )
    UpperCAmelCase_											=  []
    UpperCAmelCase_											=  ''''''

    for i in range(0 ,  len(__UpperCamelCase   ) + 1 ,  __UpperCamelCase   ):
        UpperCAmelCase_				,							UpperCAmelCase_				,							UpperCAmelCase_											=  __decrypt_part(message[i : i + period] ,  __UpperCamelCase   )

        for j in range(0 ,  len(__UpperCamelCase   )   ):
            decrypted_numeric.append(a[j] + b[j] + c[j]   )

    for each in decrypted_numeric:
        decrypted += number_to_character[each]

    return decrypted


if __name__ == "__main__":
 _lowerCamelCase    				=		'DEFEND THE EAST WALL OF THE CASTLE.'
 _lowerCamelCase    				=		encrypt_message(msg, 'EPSDUCVWYM.ZLKXNBTFGORIJHAQ')
 _lowerCamelCase    				=		decrypt_message(encrypted, 'EPSDUCVWYM.ZLKXNBTFGORIJHAQ')
 print(F"Encrypted: {encrypted}\nDecrypted: {decrypted}")











import decimal




def       SCREAMING_SNAKE_CASE			( )						->							int:
    UpperCAmelCase_											=  0
    UpperCAmelCase_											=  decimal.Context(prec=105   )
    for i in range(2 ,  100   ):
        UpperCAmelCase_											=  decimal.Decimal(__UpperCamelCase   )
        UpperCAmelCase_											=  number.sqrt(__UpperCamelCase   )
        if len(str(__UpperCamelCase   )   ) > 1:
            answer += int(str(__UpperCamelCase   )[0]   )
            UpperCAmelCase_											=  str(__UpperCamelCase   )[2:101]
            answer += sum(int(__UpperCamelCase   ) for x in sqrt_number_str   )
    return answer


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 print(F"{solution() = }")





