



'''simple docstring'''




from __future__ import annotations

import pandas as pd


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[int]       ,      _lowerCamelCase:   list[int]       ,      _lowerCamelCase:   int					):
		__SCREAMING_SNAKE_CASE       :		List[Any]           =		[0] * no_of_processes
		__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		[0] * no_of_processes
		# Copy the burst time into remaining_time[]
		for i in range(_lowerCamelCase					):
				__SCREAMING_SNAKE_CASE       :		Optional[int]           =		burst_time[i]

		__SCREAMING_SNAKE_CASE       :		Optional[int]           =		0
		__SCREAMING_SNAKE_CASE       :		Any           =		0
		__SCREAMING_SNAKE_CASE       :		Dict           =		9_99_99_99_99
		__SCREAMING_SNAKE_CASE       :		Tuple           =		0
		__SCREAMING_SNAKE_CASE       :		int           =		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:
										__SCREAMING_SNAKE_CASE       :		Tuple           =		remaining_time[j]
										__SCREAMING_SNAKE_CASE       :		Dict           =		j
										__SCREAMING_SNAKE_CASE       :		str           =		True

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

				__SCREAMING_SNAKE_CASE       :		str           =		remaining_time[short]
				if minm == 0:
						__SCREAMING_SNAKE_CASE       :		int           =		9_99_99_99_99

				if remaining_time[short] == 0:
						complete += 1
						__SCREAMING_SNAKE_CASE       :		List[str]           =		False

						# Find finish time of current process
						__SCREAMING_SNAKE_CASE       :		Tuple           =		increment_time + 1

						# Calculate waiting time
						__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		finish_time - arrival_time[short]
						__SCREAMING_SNAKE_CASE       :		List[Any]           =		finar - burst_time[short]

						if waiting_time[short] < 0:
								__SCREAMING_SNAKE_CASE       :		str           =		0

        # Increment time
				increment_time += 1
		return waiting_time


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[int]       ,      _lowerCamelCase:   int       ,      _lowerCamelCase:   list[int]					):
		__SCREAMING_SNAKE_CASE       :		List[Any]           =		[0] * no_of_processes
		for i in range(_lowerCamelCase					):
				__SCREAMING_SNAKE_CASE       :		Optional[int]           =		burst_time[i] + waiting_time[i]
		return turn_around_time


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[int]       ,      _lowerCamelCase:   list[int]       ,      _lowerCamelCase:   int					):
		__SCREAMING_SNAKE_CASE       :		Optional[int]           =		0
		__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		0
		for i in range(_lowerCamelCase					):
				__SCREAMING_SNAKE_CASE       :		Optional[Any]           =		total_waiting_time + waiting_time[i]
				__SCREAMING_SNAKE_CASE       :		str           =		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''')
						UpperCamelCase__       :	List[Any]    = int(input())
						UpperCamelCase__       :	Optional[int]    = [0] * no_of_processes
						UpperCamelCase__       :	Any    = [0] * no_of_processes
						UpperCamelCase__       :	Optional[Any]    = 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))
												UpperCamelCase__  ,UpperCamelCase__       :	Any    = map(int, input().split())

						UpperCamelCase__       :	Tuple    = calculate_waitingtime(arrival_time, burst_time, no_of_processes)

						UpperCamelCase__       :	List[Any]    = burst_time
						UpperCamelCase__       :	List[str]    = no_of_processes
						UpperCamelCase__       :	Union[str, Any]    = waiting_time
						UpperCamelCase__       :	str    = calculate_turnaroundtime(bt, n, wt)

						calculate_average_times(waiting_time, turn_around_time, no_of_processes)

						UpperCamelCase__       :	List[str]    = 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'''




def 				lowerCAmelCase_   (	_lowerCamelCase:   float       ,      _lowerCamelCase:   list[float]					):
		if discount_rate < 0:
				raise ValueError("""Discount rate cannot be negative"""					)
		if not cash_flows:
				raise ValueError("""Cash flows list cannot be empty"""					)
		__SCREAMING_SNAKE_CASE       :		List[str]           =		sum(
		    cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_lowerCamelCase					)					)
		return round(_lowerCamelCase       ,      ndigits=2					)


if __name__ == "__main__":
						import doctest

						doctest.testmod()