In this article, we will write a python program to figure out how much time we will need to contribute to a project as a freelancer, but before that, let us go through the below problem first!
You are the best freelancer in the city. Everybody knows you, but what they don’t know, is that you are actually offloading your work to other freelancers and you rarely need to do any work. You’re living the life!
Giving the amount of time in minutes needed to complete the project and an array of pair values representing other freelancers’ time in [Hours, Minutes] format ie. [[2, 33], [3, 44]] calculate how much time you will need to contribute to the project (if at all) and return a string depending on the case.
If we need to contribute time to the project then return "I need to work x hour(s) and y minute(s)" If we don't have to contribute any time to the project then return "Easy Money!"
- We will create a python f
unctionwhich will first count the total available time in minutes for all the freelancers.
- Then we will subtract the total available time from the time you need to complete the project.
- If there are still some minutes remain then we will convert the time to the hour and minute accordingly.
- Finally, return either one of the above strings.
def work_needed(projectMinutes, freeLancers): total_minutes_freelancer = 0 for arr in freeLancers: total_minutes_freelancer+= arr * 60 + arr working_minutes = projectMinutes - total_minutes_freelancer if(working_minutes <= 0): return "Easy Money!" else: hour = int(working_minutes/60) minute = working_minutes % 60 return "I need to work " + str(hour) + " hour(s) and " + str(minute) + " minute(s)"
There we go, I hope you enjoy this post. If you have better idea then do leave your solution below this post.
Am I updating this website daily? Yes, I do, but I maybe will not write a new post regarding Python every day. Therefore if you like this website then maybe you can subscribe to the other