+ 4
how i can get the lowest price on every job here
i have this job 1 job 2 job 3 job 4 A 5 7 4 3 B 10 3 7 6 C 7 4 5 3 D 3 1 2 3 i have that question there are 4 workers and jobs, each worker has the price of each job, how can i look for which workers will work at the lowest prices with different workers ex : price of a , b, c, d is 5+3+5+3=16 price of a , b, d, c is 5+3+2+3=13
12 Respuestas
+ 3
There are probably better ways than trying every combination, but they might be more difficult to implement.
Here's what I would do: Find every combination of A, B, C, D, for example with nested loops. Find the price of each combination and compare it with the minimum price that is stored in a variable. If the price of the combination is lower, update the minimum price variable accordingly. You can store the optimal combination in a string variable or in an array of strings as there are (spoiler warning) two combinations that share the lowest price.
+ 3
No problem
+ 2
I could post a possible solution in python but I don't think it would help you implement the pattern described above because the python code is totally different 🤓
+ 2
thanks for your hard work
+ 2
Sounds like this:
https://code.sololearn.com/cHy7K2E8Oy48/?ref=app
+ 1
Daniel (kabura) I think that would lead to worker D doing every job (because he's the cheapest in every category), but as I understand it, every worker can only do one job, so it has to be a combination of A-B-C-D.
+ 1
Yes, there are fancy algorithms (like https://en.m.wikipedia.org/wiki/Hungarian_algorithm ), but what Anna said works perfectly, and is fairly simple to implement.
+ 1
what the main issue is i dont know how to write it to code 😞
+ 1
oh its okay
0
You can create int pirice tables for each employee, and then find the smallest value in each table
0
i just want to know how it works