-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWise_Project.py
62 lines (52 loc) · 1.8 KB
/
Wise_Project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from collections import deque
def calculate_delay_time(arrival_times, durations):
total_delay = 0
job_queue = deque()
current_time = arrival_times[0]
for i, arrival_time in enumerate(arrival_times):
while current_time < arrival_time:
if job_queue:
job = job_queue.popleft()
total_delay += current_time - job['arrival_time']
current_time += 1
job = {'arrival_time': arrival_time, 'duration': durations[i]}
job_queue.append(job)
current_time += 1
# Finish remaining jobs in the queue
while job_queue:
job = job_queue.popleft()
total_delay += current_time - job['arrival_time']
return total_delay
# Input data for each day
days = ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY']
arrival_times = [
[8, 12], # Monday
[8, 9, 11], # Tuesday
[8, 10], # Wednesday
[8, 9, 10], # Thursday
[8, 12], # Friday
]
durations = [
[4, 6], # Monday
[4, 6, 5], # Tuesday
[4, 6], # Wednesday
[4, 6, 5], # Thursday
[4, 6], # Friday
]
# Calculate average delay for each day
average_delays = []
for day in range(len(days)):
delay_time = calculate_delay_time(arrival_times[day], durations[day])
average_delay = delay_time / len(arrival_times[day])
average_delays.append(average_delay)
# Calculate overall average delay
total_jobs = sum(len(arrival_times[day]) for day in range(len(days)))
overall_delay = sum(average_delays) / len(days)
# Print the table
print("DAY")
for day, average_delay in zip(days, average_delays):
print(day)
print("AVERAGE DELAY")
for average_delay in average_delays:
print(f"{average_delay:.2f} minutes")
print(f"Overall Average Delay: {overall_delay:.2f} minutes")