


"""simple docstring"""







from __future__ import annotations

import pandas as pd


def      lowercase			(				A_  ,   A_  ,   A_       )->      Optional[Any]:
  '''simple docstring'''







  a						:		Optional[int]      							=			[0] * no_of_processes
  a						:		str      							=			[0] * no_of_processes
  # Copy the burst time into remaining_time[]
  for i in range(lowerCAmelCase_       ):
    a						:		int      							=			burst_time[i]

  a						:		Union[str, Any]      							=			0
  a						:		Union[str, Any]      							=			0
  a						:		str      							=			999_999_999
  a						:		List[Any]      							=			0
  a						:		List[str]      							=			False

  # Process until all processes are completed
  while complete != no_of_processes:
    for j in range(lowerCAmelCase_       ):
      if arrival_time[j] <= increment_time and remaining_time[j] > 0:
        if remaining_time[j] < minm:
          a						:		Any      							=			remaining_time[j]
          a						:		Optional[int]      							=			j
          a						:		Dict      							=			True

    if not check:
      increment_time += 1
      continue
    remaining_time[short] -= 1

    a						:		Dict      							=			remaining_time[short]
    if minm == 0:
      a						:		int      							=			999_999_999

    if remaining_time[short] == 0:
      complete += 1
      a						:		Tuple      							=			False

      # Find finish time of current process
      a						:		Any      							=			increment_time + 1

      # Calculate waiting time
      a						:		str      							=			finish_time - arrival_time[short]
      a						:		Optional[int]      							=			finar - burst_time[short]

      if waiting_time[short] < 0:
        a						:		List[str]      							=			0

        # Increment time
    increment_time += 1
  return waiting_time


def      lowercase			(				A_  ,   A_  ,   A_       )->      Union[str, Any]:
  '''simple docstring'''







  a						:		str      							=			[0] * no_of_processes
  for i in range(lowerCAmelCase_       ):
    a						:		Optional[Any]      							=			burst_time[i] + waiting_time[i]
  return turn_around_time


def      lowercase			(				A_  ,   A_  ,   A_       )->      Optional[int]:
  '''simple docstring'''







  a						:		Any      							=			0
  a						:		Optional[Any]      							=			0
  for i in range(lowerCAmelCase_       ):
    a						:		str      							=			total_waiting_time + waiting_time[i]
    a						:		Union[str, Any]      							=			total_turn_around_time + turn_around_time[i]
  print(F'''Average waiting time = {total_waiting_time / no_of_processes:.5f}'''       )
  print("Average turn around time ="  ,   total_turn_around_time / no_of_processes       )


if __name__ == "__main__":
 print("""Enter how many process you want to analyze""")
 __lowercase    					=      int(input())
 __lowercase    					=      [0] * no_of_processes
 __lowercase    					=      [0] * no_of_processes
 __lowercase    					=      list(range(1, no_of_processes + 1))

 for i in range(no_of_processes):
  print("""Enter the arrival time and burst time for process:--""" + str(i + 1))
  __lowercase    					=      map(int, input().split())

 __lowercase    					=      calculate_waitingtime(arrival_time, burst_time, no_of_processes)

 __lowercase    					=      burst_time
 __lowercase    					=      no_of_processes
 __lowercase    					=      waiting_time
 __lowercase    					=      calculate_turnaroundtime(bt, n, wt)

 calculate_average_times(waiting_time, turn_around_time, no_of_processes)

 __lowercase    					=      pd.DataFrame(
     list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)),
     columns=[
         """Process""",
         """BurstTime""",
         """ArrivalTime""",
         """WaitingTime""",
         """TurnAroundTime""",
     ],
 )

 # Printing the dataFrame
 pd.set_option("""display.max_rows""", fcfs.shape[0] + 1)
 print(fcfs)










"""simple docstring"""







import unittest

from transformers.testing_utils import CaptureStdout
from transformers.tools.python_interpreter import evaluate




def    UpperCAmelCase__       (lowerCAmelCase_   ):




					'''simple docstring'''


					return x + 2




class  UpperCamelCase_	( unittest.TestCase):

	"""simple docstring"""





	def   UpperCAmelCase_      ( self			:				Any   )       ->	Any:
						__SCREAMING_SNAKE_CASE						   =				"x = 3"
						__SCREAMING_SNAKE_CASE						   =				{}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						assert result == 3
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3}   )

						__SCREAMING_SNAKE_CASE						   =				"x = y"
						__SCREAMING_SNAKE_CASE						   =				{"y": 5}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						# evaluate returns the value of the last assignment.
						assert result == 5
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 5, "y": 5}   )




	def   UpperCAmelCase_      ( self			:				Dict   )       ->	List[str]:
						__SCREAMING_SNAKE_CASE						   =				"y = add_two(x)"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{"add_two": add_two}			,			state=UpperCAmelCase__   )
						assert result == 5
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "y": 5}   )

						# Won't work without the tool
						with CaptureStdout() as out:
											__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						assert result is None
						assert "tried to execute add_two" in out.out




	def   UpperCAmelCase_      ( self			:				List[Any]   )       ->	List[Any]:
						__SCREAMING_SNAKE_CASE						   =				"x = 3"
						__SCREAMING_SNAKE_CASE						   =				{}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						assert result == 3
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3}   )




	def   UpperCAmelCase_      ( self			:				str   )       ->	Any:
						__SCREAMING_SNAKE_CASE						   =				"test_dict = {'x': x, 'y': add_two(x)}"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{"add_two": add_two}			,			state=UpperCAmelCase__   )
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "y": 5}   )
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "test_dict": {"x": 3, "y": 5}}   )




	def   UpperCAmelCase_      ( self			:				int   )       ->	Optional[Any]:
						__SCREAMING_SNAKE_CASE						   =				"x = 3\ny = 5"
						__SCREAMING_SNAKE_CASE						   =				{}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						# evaluate returns the value of the last assignment.
						assert result == 5
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "y": 5}   )




	def   UpperCAmelCase_      ( self			:				Any   )       ->	Any:
						__SCREAMING_SNAKE_CASE						   =				"text = f'This is x: {x}.'"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						# evaluate returns the value of the last assignment.
						assert result == "This is x: 3."
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "text": "This is x: 3."}   )




	def   UpperCAmelCase_      ( self			:				Union[str, Any]   )       ->	Optional[int]:
						__SCREAMING_SNAKE_CASE						   =				"if x <= 3:\n    y = 2\nelse:\n    y = 5"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						# evaluate returns the value of the last assignment.
						assert result == 2
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "y": 2}   )

						__SCREAMING_SNAKE_CASE						   =				{"x": 8}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						# evaluate returns the value of the last assignment.
						assert result == 5
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 8, "y": 5}   )




	def   UpperCAmelCase_      ( self			:				Tuple   )       ->	str:
						__SCREAMING_SNAKE_CASE						   =				"test_list = [x, add_two(x)]"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{"add_two": add_two}			,			state=UpperCAmelCase__   )
						self.assertListEqual(UpperCAmelCase__			,			[3, 5]   )
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "test_list": [3, 5]}   )




	def   UpperCAmelCase_      ( self			:				Any   )       ->	int:
						__SCREAMING_SNAKE_CASE						   =				"y = x"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{}			,			state=UpperCAmelCase__   )
						assert result == 3
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "y": 3}   )




	def   UpperCAmelCase_      ( self			:				Tuple   )       ->	int:
						__SCREAMING_SNAKE_CASE						   =				"test_list = [x, add_two(x)]\ntest_list[1]"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{"add_two": add_two}			,			state=UpperCAmelCase__   )
						assert result == 5
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "test_list": [3, 5]}   )

						__SCREAMING_SNAKE_CASE						   =				"test_dict = {'x': x, 'y': add_two(x)}\ntest_dict['y']"
						__SCREAMING_SNAKE_CASE						   =				{"x": 3}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{"add_two": add_two}			,			state=UpperCAmelCase__   )
						assert result == 5
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 3, "test_dict": {"x": 3, "y": 5}}   )




	def   UpperCAmelCase_      ( self			:				List[str]   )       ->	List[str]:
						__SCREAMING_SNAKE_CASE						   =				"x = 0\nfor i in range(3):\n    x = i"
						__SCREAMING_SNAKE_CASE						   =				{}
						__SCREAMING_SNAKE_CASE						   =				evaluate(UpperCAmelCase__			,			{"range": range}			,			state=UpperCAmelCase__   )
						assert result == 2
						self.assertDictEqual(UpperCAmelCase__			,			{"x": 2, "i": 2}   )
