






from __future__ import annotations



def       _SCREAMING_SNAKE_CASE    (			__lowercase :      list[list[int]]     )    ->   bool:





    """simple docstring"""

    __A       =						len(__lowercase     )
    # We need to create solution object to save path.
    __A       =						[[0 for _ in range(__lowercase     )] for _ in range(__lowercase     )]
    __A       =						run_maze(__lowercase      ,					0      ,					0      ,					__lowercase     )
    if solved:
        print("""\n""".join(str(__lowercase     ) for row in solutions     )     )
    else:
        print("""No solution exists!"""     )
    return solved



def       _SCREAMING_SNAKE_CASE    (			__lowercase :      list[list[int]]      ,					__lowercase :      int      ,					__lowercase :      int      ,					__lowercase :      list[list[int]]     )    ->   bool:





    """simple docstring"""

    __A       =						len(__lowercase     )
    # Final check point.
    if i == j == (size - 1):
        __A       =						1
        return True

    __A       =						(not i < 0) and (not j < 0)  # Check lower bounds
    __A       =						(i < size) and (j < size)  # Check upper bounds

    if lower_flag and upper_flag:
        # check for already visited and block points.
        __A       =						(not solutions[i][j]) and (not maze[i][j])
        if block_flag:
            # check visited
            __A       =						1

            # check for directions
            if (
                run_maze(__lowercase      ,					i + 1      ,					__lowercase      ,					__lowercase     )
                or run_maze(__lowercase      ,					__lowercase      ,					j + 1      ,					__lowercase     )
                or run_maze(__lowercase      ,					i - 1      ,					__lowercase      ,					__lowercase     )
                or run_maze(__lowercase      ,					__lowercase      ,					j - 1      ,					__lowercase     )
            ):
                return True

            __A       =						0
            return False
    return False


if __name__ == "__main__":
  import doctest

  doctest.testmod()












def       _SCREAMING_SNAKE_CASE    (			__lowercase :      str     )    ->   str:





    """simple docstring"""

    __A       =						""""""
    for ch in key:
        if ch == " " or ch not in key_no_dups and ch.isalpha():
            key_no_dups += ch
    return key_no_dups



def       _SCREAMING_SNAKE_CASE    (			__lowercase :      str     )    ->   dict[str, str]:





    """simple docstring"""

    __A       =						[chr(i + 6_5     ) for i in range(2_6     )]
    # Remove duplicate characters from key
    __A       =						remove_duplicates(key.upper()     )
    __A       =						len(__lowercase     )
    # First fill cipher with key characters
    __A       =						{alphabet[i]: char for i, char in enumerate(__lowercase     )}
    # Then map remaining characters in alphabet to
    # the alphabet from the beginning
    for i in range(len(__lowercase     )      ,					2_6     ):
        __A       =						alphabet[i - offset]
        # Ensure we are not mapping letters to letters previously mapped
        while char in key:
            offset -= 1
            __A       =						alphabet[i - offset]
        __A       =						char
    return cipher_alphabet



def       _SCREAMING_SNAKE_CASE    (			__lowercase :      str      ,					__lowercase :      dict[str, str]     )    ->   str:





    """simple docstring"""

    return "".join(cipher_map.get(__lowercase      ,					__lowercase     ) for ch in message.upper()     )



def       _SCREAMING_SNAKE_CASE    (			__lowercase :      str      ,					__lowercase :      dict[str, str]     )    ->   str:





    """simple docstring"""

    __A       =						{v: k for k, v in cipher_map.items()}
    return "".join(rev_cipher_map.get(__lowercase      ,					__lowercase     ) for ch in message.upper()     )



def       _SCREAMING_SNAKE_CASE    (			)    ->   None:





    """simple docstring"""

    __A       =						input("""Enter message to encode or decode: """     ).strip()
    __A       =						input("""Enter keyword: """     ).strip()
    __A       =						input("""Encipher or decipher? E/D:"""     ).strip()[0].lower()
    try:
        __A       =						{"""e""": encipher, """d""": decipher}[option]
    except KeyError:
        raise KeyError("""invalid input option"""     )
    __A       =						create_cipher_map(__lowercase     )
    print(func(__lowercase      ,					__lowercase     )     )


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()




