Skip to content

Commit e2656ed

Browse files
job_sequencing
1 parent 36b4200 commit e2656ed

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

.idea/workspace.xml

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

job_sequencing_deadline.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
2+
def sequencing(arr):
3+
#### sorting to get the max no. of job to schedule
4+
arr.sort(key=lambda x: x[1], reverse=True)
5+
t = arr[0][1]
6+
#### sorting jobs according to profit in decreasing order
7+
arr.sort(key=lambda x: x[2], reverse=True)
8+
slots=[False]*t
9+
jobs=['empty']*t
10+
for i in range(len(arr)):
11+
for j in range(min(t-1,arr[i][1]-1),-1,-1):
12+
if slots[j]==False:
13+
slots[j]=True
14+
jobs[j]=arr[i][0]
15+
break
16+
return jobs
17+
18+
119
arr = [['a', 2, 100],
220
['b', 1, 19],
321
['c', 2, 27],
422
['d', 1, 25],
523
['e', 3, 15]]
624

7-
arr.sort(key=lambda x:x[2],reverse=True)
8-
9-
print(arr)
25+
print(sequencing(arr))

0 commit comments

Comments
 (0)