Skip to content

Create code.py #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
n = int(input("Please enter the number of jobs: "))
jobs = []
for i in range(n):
start_time = int(input("Please enter start time: "))
end_time = int(input("Please enter end time: "))
profit = int(input("Please enter profit value: "))
jobs.append([start_time, end_time, profit])

#Sort the jobs in ascending order of start time
jobs.sort(key = lambda x:x[0])

#Lokesh picks job with maximum profit
max_profit = 0
for job in jobs:
if job[2] > max_profit:
max_profit = job[2]
max_job = job

#Remove the selected job from the jobs list
jobs.remove(max_job)

#Calculate the number of jobs and total earnings left for other employees
number_jobs = len(jobs)
total_earnings = 0
for job in jobs:
total_earnings += job[2]

print("Number of jobs left for other employees: ", number_jobs)
print("Total earnings left for other employees: ", total_earnings)