We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ea3760b + 485823d commit 7df63d9Copy full SHA for 7df63d9
Greedy Algorithms/machineselect.py
@@ -0,0 +1,29 @@
1
+if __name__ == '__main__':
2
+ m=int(input("Enter number of machines:"))
3
+ n=int(input("Enter number of jobs:"))
4
+ t=[]
5
+ for i in range(n):
6
+ print("Enter time to complete jon no ",i+1)
7
+ a=int(input())
8
+ t.append(a)
9
+ #print(t)
10
+ M=[0]*m
11
+ k=0
12
+ #print(M)
13
+ for j in range(m):
14
+ if M[j]==0:
15
+ M[j]+=t[k]
16
+ k=k+1
17
18
+ for i in range(n-m):
19
+ x=min(M)
20
+ for l in range(m):
21
+ if M[l]==x:
22
+ z=l
23
+ #print(l)
24
+ M[z]+=t[k]
25
26
+ print("Max span= %d"%max(M))
27
+
28
29
0 commit comments