


"""simple docstring"""



from __future__ import annotations

import pandas as pd







def   __lowerCAmelCase						(						lowercase  :  list[int]						,							lowercase  :  list[int]						,							lowercase  :  int )	->						list[int]:


    """simple docstring"""





    snake_case    :      Tuple      					=    [0] * no_of_processes
    snake_case    :      List[str]      					=    [0] * no_of_processes
    # Copy the burst time into remaining_time[]
    for i in range(lowercase ):
        snake_case    :      Any      					=    burst_time[i]

    snake_case    :      Optional[int]      					=    0
    snake_case    :      Optional[Any]      					=    0
    snake_case    :      Union[str, Any]      					=    9_9999_9999
    snake_case    :      Optional[Any]      					=    0
    snake_case    :      Any      					=    False

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

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

        snake_case    :      Optional[int]      					=    remaining_time[short]
        if minm == 0:
            snake_case    :      Union[str, Any]      					=    9_9999_9999

        if remaining_time[short] == 0:
            complete += 1
            snake_case    :      Optional[int]      					=    False

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

            # Calculate waiting time
            snake_case    :      Dict      					=    finish_time - arrival_time[short]
            snake_case    :      Any      					=    finar - burst_time[short]

            if waiting_time[short] < 0:
                snake_case    :      Optional[Any]      					=    0

        # Increment time
        increment_time += 1
    return waiting_time







def   __lowerCAmelCase						(						lowercase  :  list[int]						,							lowercase  :  int						,							lowercase  :  list[int] )	->						list[int]:


    """simple docstring"""





    snake_case    :      int      					=    [0] * no_of_processes
    for i in range(lowercase ):
        snake_case    :      Any      					=    burst_time[i] + waiting_time[i]
    return turn_around_time







def   __lowerCAmelCase						(						lowercase  :  list[int]						,							lowercase  :  list[int]						,							lowercase  :  int )	->						None:


    """simple docstring"""





    snake_case    :      int      					=    0
    snake_case    :      int      					=    0
    for i in range(lowercase ):
        snake_case    :      Tuple      					=    total_waiting_time + waiting_time[i]
        snake_case    :      List[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""")
  __snake_case   			=    int(input())
  __snake_case   			=    [0] * no_of_processes
  __snake_case   			=    [0] * no_of_processes
  __snake_case   			=    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))
    __snake_case			,		__snake_case   			=    map(int, input().split())

  __snake_case   			=    calculate_waitingtime(arrival_time, burst_time, no_of_processes)

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

  calculate_average_times(waiting_time, turn_around_time, no_of_processes)

  __snake_case   			=    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						(						lowercase  :  list )	->						int:


    """simple docstring"""





    if not grid or not grid[0]:
        raise TypeError("The grid does not contain the appropriate information" )

    for cell_n in range(1						,							len(grid[0] ) ):
        grid[0][cell_n] += grid[0][cell_n - 1]
    snake_case    :      int      					=    grid[0]

    for row_n in range(1						,							len(lowercase ) ):
        snake_case    :      Optional[Any]      					=    grid[row_n]
        snake_case    :      List[str]      					=    fill_row(lowercase						,							lowercase )
        snake_case    :      Optional[int]      					=    grid[row_n]

    return grid[-1][-1]







def   __lowerCAmelCase						(						lowercase  :  list						,							lowercase  :  list )	->						list:


    """simple docstring"""





    current_row[0] += row_above[0]
    for cell_n in range(1						,							len(lowercase ) ):
        current_row[cell_n] += min(current_row[cell_n - 1]						,							row_above[cell_n] )

    return current_row


if __name__ == "__main__":
  import doctest

  doctest.testmod()





