


'''simple docstring'''



from __future__ import annotations

import string
from itertools import cycle, product
from pathlib import Path

__A	=(
    string.ascii_letters + string.digits + string.punctuation + string.whitespace
)
__A	=[ord(letter) for letter in string.ascii_lowercase]
__A	={ord(char) for char in VALID_CHARS}

__A	=['the', 'be', 'to', 'of', 'and', 'in', 'that', 'have']







def     _UpperCamelCase      (		UpperCamelCase__ ,      UpperCamelCase__					):
			UpperCAmelCase__  :					str        =     ""
			UpperCAmelCase__  :					int
			UpperCAmelCase__  :					int
			UpperCAmelCase__  :					int

			for keychar, cipherchar in zip(cycle(UpperCamelCase__					) ,      UpperCamelCase__					):
						UpperCAmelCase__  :					List[Any]        =     cipherchar ^ keychar
						if decodedchar not in VALID_INTS:
									return None
						decoded += chr(UpperCamelCase__					)

			return decoded







def     _UpperCamelCase      (		UpperCamelCase__					):
			UpperCAmelCase__  :					list[str]        =     []
			for key in product(UpperCamelCase__ ,      repeat=3					):
						UpperCAmelCase__  :					Optional[int]        =     try_key(UpperCamelCase__ ,      UpperCamelCase__					)
						if encoded is not None:
									possibles.append(UpperCamelCase__					)
			return possibles







def     _UpperCamelCase      (		UpperCamelCase__ ,      UpperCamelCase__					):
			return [possible for possible in possibles if common_word in possible.lower()]







def     _UpperCamelCase      (		UpperCamelCase__ = "p059_cipher.txt"					):
			UpperCAmelCase__  :					list[int]
			UpperCAmelCase__  :					list[str]
			UpperCAmelCase__  :					str
			UpperCAmelCase__  :					str
			UpperCAmelCase__  :					str        =     Path(UpperCamelCase__					).parent.joinpath(UpperCamelCase__					).read_text(encoding="""utf-8"""					)

			UpperCAmelCase__  :					int        =     [int(UpperCamelCase__					) for number in data.strip().split(""","""					)]

			UpperCAmelCase__  :					Any        =     filter_valid_chars(UpperCamelCase__					)
			for common_word in COMMON_WORDS:
						UpperCAmelCase__  :					int        =     filter_common_word(UpperCamelCase__ ,      UpperCamelCase__					)
						if len(UpperCamelCase__					) == 1:
									break

			UpperCAmelCase__  :					str        =     possibles[0]
			return sum(ord(UpperCamelCase__					) for char in decoded_text					)


if __name__ == "__main__":
		print(f"""{solution() = }""")



'''simple docstring'''



from itertools import permutations







def     _UpperCamelCase      (		UpperCamelCase__					):
			if num[3] % 2 != 0:
						return False

			if (num[2] + num[3] + num[4]) % 3 != 0:
						return False

			if num[5] % 5 != 0:
						return False

			UpperCAmelCase__  :					Optional[int]        =     [7, 1_1, 1_3, 1_7]
			for i, test in enumerate(UpperCamelCase__					):
						if (num[i + 4] * 1_0_0 + num[i + 5] * 1_0 + num[i + 6]) % test != 0:
									return False
			return True







def     _UpperCamelCase      (		UpperCamelCase__ = 1_0					):
			return sum(
			    int("""""".join(map(UpperCamelCase__ ,      UpperCamelCase__					)					)					)
			    for num in permutations(range(UpperCamelCase__					)					)
			    if is_substring_divisible(UpperCamelCase__					)					)


if __name__ == "__main__":
		print(f"""{solution() = }""")