





"""simple docstring"""




from __future__ import annotations

from typing import Generic, TypeVar

UpperCamelCase_	 =TypeVar("""T""")




class 					_a		( Generic[T]							):






				def __init__(					self						:       str,					lowerCAmelCase__						:       T				)      -> Optional[Any]:




										'''simple docstring'''



										_UpperCamelCase     :   str      =       data  # Assign data
										_UpperCamelCase     :   Node[T] | None      =       None  # Initialize next as null
										_UpperCamelCase     :   Node[T] | None      =       None  # Initialize prev as null




class 					_a		( Generic[T]							):






				def __init__(					self						:       Dict				)      -> None:




										'''simple docstring'''



										_UpperCamelCase     :   Node[T] | None      =       None






				def 							snake_case      (					self						:       Union[str, Any],					lowerCAmelCase__						:       T				)      -> None:




										'''simple docstring'''



										if self.head is None:
																_UpperCamelCase     :   Tuple      =       Node(lowerCAmelCase__				)
										else:
																_UpperCamelCase     :   str      =       Node(lowerCAmelCase__				)
																_UpperCamelCase     :   List[str]      =       new_node
																_UpperCamelCase     :   Union[str, Any]      =       self.head
																_UpperCamelCase     :   str      =       None
																_UpperCamelCase     :   Optional[Any]      =       new_node






				def 							snake_case      (					self						:       int				)      -> T | None:




										'''simple docstring'''



										if self.head is None:
																return None
										else:
																assert self.head is not None
																_UpperCamelCase     :   Optional[int]      =       self.head.data
																_UpperCamelCase     :   Optional[int]      =       self.head.next
																if self.head is not None:
																						_UpperCamelCase     :   List[Any]      =       None
																return temp






				def 							snake_case      (					self						:       Dict				)      -> T | None:




										'''simple docstring'''



										return self.head.data if self.head is not None else None






				def __len__(					self						:       Optional[int]				)      -> int:




										'''simple docstring'''



										_UpperCamelCase     :   Dict      =       self.head
										_UpperCamelCase     :   Optional[Any]      =       0
										while temp is not None:
																count += 1
																_UpperCamelCase     :   int      =       temp.next
										return count






				def 							snake_case      (					self						:       List[Any]				)      -> bool:




										'''simple docstring'''



										return self.head is None






				def 							snake_case      (					self						:       Union[str, Any]				)      -> None:




										'''simple docstring'''



										print('''stack elements are:'''				)
										_UpperCamelCase     :   Optional[int]      =       self.head
										while temp is not None:
																print(temp.data,					end='''->'''				)
																_UpperCamelCase     :   List[str]      =       temp.next


# Code execution starts here
if __name__ == "__main__":
						# Start with the empty stack
						UpperCamelCase_	 =Stack()

						# Insert 4 at the beginning. So stack becomes 4->None
						print("""Stack operations using Doubly LinkedList""")
						stack.push(4)

						# Insert 5 at the beginning. So stack becomes 4->5->None
						stack.push(5)

						# Insert 6 at the beginning. So stack becomes 4->5->6->None
						stack.push(6)

						# Insert 7 at the beginning. So stack becomes 4->5->6->7->None
						stack.push(7)

						# Print the stack
						stack.print_stack()

						# Print the top element
						print("""\nTop element is """, stack.top())

						# Print the stack size
						print("""Size of the stack is """, len(stack))

						# pop the top element
						stack.pop()

						# pop the top element
						stack.pop()

						# two elements have now been popped off
						stack.print_stack()

						# Print True if the stack is empty else False
						print("""\nstack is empty:""", stack.is_empty())










"""simple docstring"""




import os
import sys
import time

from . import transposition_cipher as trans_cipher





def 			a_							(				):
						_UpperCamelCase     :   Dict      =       '''Prehistoric Men.txt'''
						_UpperCamelCase     :   Optional[Any]      =       '''Output.txt'''
						_UpperCamelCase     :   Any      =       int(input('''Enter key: '''  )  )
						_UpperCamelCase     :   Optional[Any]      =       input('''Encrypt/Decrypt [e/d]: '''  )

						if not os.path.exists(_lowercase  ):
												print(F"""File {input_file} does not exist. Quitting..."""  )
												sys.exit()
						if os.path.exists(_lowercase  ):
												print(F"""Overwrite {output_file}? [y/n]"""  )
												_UpperCamelCase     :   Optional[int]      =       input('''> '''  )
												if not response.lower().startswith('''y'''  ):
																		sys.exit()

						_UpperCamelCase     :   List[str]      =       time.time()
						if mode.lower().startswith('''e'''  ):
												with open(_lowercase  ) as f:
																		_UpperCamelCase     :   Optional[int]      =       f.read()
												_UpperCamelCase     :   List[str]      =       trans_cipher.encrypt_message(_lowercase			,		_lowercase  )
						elif mode.lower().startswith('''d'''  ):
												with open(_lowercase  ) as f:
																		_UpperCamelCase     :   Dict      =       f.read()
												_UpperCamelCase     :   Any      =       trans_cipher.decrypt_message(_lowercase			,		_lowercase  )

						with open(_lowercase			,		'''w'''  ) as output_obj:
												output_obj.write(_lowercase  )

						_UpperCamelCase     :   List[str]      =       round(time.time() - start_time			,		2  )
						print(('''Done (''', total_time, '''seconds )''')  )


if __name__ == "__main__":
						main()



