



'''simple docstring'''





from __future__ import annotations

import pandas as pd



def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ):
			lowercase__					  =				[0] * no_of_processes
			lowercase__					  =				[0] * no_of_processes
			# Copy the burst time into remaining_time[]
			for i in range(lowerCamelCase__  ):
						lowercase__					  =				burst_time[i]

			lowercase__					  =				0
			lowercase__					  =				0
			lowercase__					  =				9_9999_9999
			lowercase__					  =				0
			lowercase__					  =				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:
															lowercase__					  =				remaining_time[j]
															lowercase__					  =				j
															lowercase__					  =				True

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

						lowercase__					  =				remaining_time[short]
						if minm == 0:
									lowercase__					  =				9_9999_9999

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

									# Find finish time of current process
									lowercase__					  =				increment_time + 1

									# Calculate waiting time
									lowercase__					  =				finish_time - arrival_time[short]
									lowercase__					  =				finar - burst_time[short]

									if waiting_time[short] < 0:
												lowercase__					  =				0

        # Increment time
						increment_time += 1
			return waiting_time



def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ):
			lowercase__					  =				[0] * no_of_processes
			for i in range(lowerCamelCase__  ):
						lowercase__					  =				burst_time[i] + waiting_time[i]
			return turn_around_time



def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ):
			lowercase__					  =				0
			lowercase__					  =				0
			for i in range(lowerCamelCase__  ):
						lowercase__					  =				total_waiting_time + waiting_time[i]
						lowercase__					  =				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_				,    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)









def __lowerCAmelCase (     SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ):
			lowercase__  ,       lowercase__					  =				len(SCREAMING_SNAKE_CASE_  ), len(grid[0]  )
			if (
			    min(SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  ) < 0
			    or row == row_length
			    or col == col_length
			    or (row, col) in visit
			    or grid[row][col] == 1
			):
						return 0
			if row == row_length - 1 and col == col_length - 1:
						return 1

			visit.add((row, col)  )

			lowercase__					  =				0
			count += depth_first_search(SCREAMING_SNAKE_CASE_						,  row + 1						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  )
			count += depth_first_search(SCREAMING_SNAKE_CASE_						,  row - 1						,  SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_  )
			count += depth_first_search(SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  col + 1						,  SCREAMING_SNAKE_CASE_  )
			count += depth_first_search(SCREAMING_SNAKE_CASE_						,  SCREAMING_SNAKE_CASE_						,  col - 1						,  SCREAMING_SNAKE_CASE_  )

			visit.remove((row, col)  )
			return count


if __name__ == "__main__":
							import doctest

							doctest.testmod()




