Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def sum_min_del(m,i,j):
- m=np.delete(m,i,axis=1)
- m=np.delete(m,j,axis=0)
- return sum(np.min(m,axis=0))
- def club_ass(m):
- vis=[-1]*len(m)# index is job
- for i in range(len(m)):
- mini=float('inf')
- k=0
- for j in range(len(m)):
- s=sum_min_del(m,i,j)+m[i][j]
- if s<mini and vis[j]==-1:
- mini=s
- k=j
- vis[k]=i
- return vis
- job_person=np.array([
- [9, 2, 7, 8],
- [6, 4, 3, 7],
- [5, 8, 1, 8],
- [7, 6, 9, 4]
- ])
- alloted_person = club_ass(job_person)
- for idx,person in enumerate(alloted_person):
- print(f'job {idx} person{person}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement