





"""simple docstring"""




from __future__ import annotations

from statistics import mean





def 			a_							(				_lowercase  ):
						_UpperCamelCase     :   Tuple      =       2
						_UpperCamelCase     :   List[Any]      =       list(_lowercase  )
						_UpperCamelCase     :   Union[str, Any]      =       [0] * len(_lowercase  )
						_UpperCamelCase     :   Optional[int]      =       0
						while True:
												_UpperCamelCase     :   Tuple      =       True
												for i, burst_time in enumerate(_lowercase  ):
																		if rem_burst_times[i] > 0:
																								_UpperCamelCase     :   Union[str, Any]      =       False
																								if rem_burst_times[i] > quantum:
																														t += quantum
																														rem_burst_times[i] -= quantum
																								else:
																														t += rem_burst_times[i]
																														_UpperCamelCase     :   Optional[int]      =       t - burst_time
																														_UpperCamelCase     :   List[str]      =       0
												if done is True:
																		return waiting_times





def 			a_							(				_lowercase			,		_lowercase  ):
						return [burst + waiting for burst, waiting in zip(_lowercase			,		_lowercase  )]


if __name__ == "__main__":
						UpperCamelCase_	 =[3, 5, 7]
						UpperCamelCase_	 =calculate_waiting_times(burst_times)
						UpperCamelCase_	 =calculate_turn_around_times(burst_times, waiting_times)
						print("""Process ID \tBurst Time \tWaiting Time \tTurnaround Time""")
						for i, burst_time in enumerate(burst_times):
												print(
												    F"  {i + 1}\t\t  {burst_time}\t\t  {waiting_times[i]}\t\t  "
												    F"{turn_around_times[i]}"
												)
						print(F"\nAverage waiting time = {mean(waiting_times):.5f}")
						print(F"Average turn around time = {mean(turn_around_times):.5f}")










"""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()



