Sitelet https://web.archive.org/web/20260217042828/https://github.com/TheAlgorithms/Python/pull/2459
Skip to content

Create Job_scheduling.py#2459

Closed
Mohitkumar6122 wants to merge 14 commits intoTheAlgorithms:masterfrom
Mohitkumar6122:patch-1
Closed

Create Job_scheduling.py#2459
Mohitkumar6122 wants to merge 14 commits intoTheAlgorithms:masterfrom
Mohitkumar6122:patch-1

Conversation

@Mohitkumar6122
Copy link

@Mohitkumar6122 Mohitkumar6122 commented Sep 21, 2020 •

Describe your change:

Added a greedy algorithim for job scheduling . this algo is frequently asked in coding interview and it is one of the famous greedy algorithim.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 7bc852f0-fbe5-11ea-a343-ef792cdaf85e

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 240b5760-fbef-11ea-a343-ef792cdaf85e

@Mohitkumar6122
Copy link
Author

How to remove trailing whitespaces warning in PEP8 format ?

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 4146f1c0-fbf1-11ea-a343-ef792cdaf85e

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: e9f9a190-fbf2-11ea-a343-ef792cdaf85e

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 983a8c60-fbf3-11ea-a343-ef792cdaf85e

@Mohitkumar6122
Copy link
Author

Finaly after 6 builds it passed xD

@cclauss
Copy link
Member

cclauss commented Sep 21, 2020

https://github.com/TheAlgorithms/Python/tree/master/scheduling is the place for scheduling algorithms.

@Mohitkumar6122
Copy link
Author

Mohitkumar6122 commented Sep 21, 2020 •

https://github.com/TheAlgorithms/Python/tree/master/scheduling is the place for scheduling algorithms.

ohh my bad, i just pasted it into greedy i will move it to scheduling ASAP.

@Mohitkumar6122
Copy link
Author

could you review my PR @cclauss

@cclauss
Copy link
Member

cclauss commented Sep 22, 2020 •

Try to bind as few things to your objects as you can. x will always be faster and easier to understand (and debug) than my_object.x.

@Mohitkumar6122
Copy link
Author

Try to bind as few things to your objects as you can. x will always be faster and easier to understand (and debug) than my_object.x.

thanks for the suggestion , i will keep it in mind.

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 4c008d90-fcbb-11ea-a56a-67316b5b87cd

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: c220e100-fcbb-11ea-a56a-67316b5b87cd

@TravisBuddy
Copy link

Travis tests have failed

Hey @Mohitkumar6122,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 0beee2d0-fcfa-11ea-a56a-67316b5b87cd

@Mohitkumar6122
Copy link
Author

@cclauss could you review my PR ?

I hope these changes help to clarify...

I have rearranged the code in a way that will BREAK THE TESTS.   I make this clearer, we will have a Job class and will remove the Schedule class and replace it with functions.  Let's keep the Job class super simple.  Its only goal is to carry around the deadline and profit for each Job so we do not move around separate list of ints.

With these changes, each of our three main functions takes in a list of jobs.  We should keep things flexible so that we could create `test_jobs_two` and run it thru all functions and get different results.
@cclauss
Copy link
Member

cclauss commented Sep 26, 2020 •

Create a Job class

I hope these changes help to clarify...

I have rearranged the code in a way that will BREAK THE TESTS. I make this clearer, we will have a Job class and will remove the Schedule class and replace it with functions. Let's keep the Job class super simple. Its only goal is to carry around the deadline and profit for each Job so that we no longer move around separate lists of ints.

With these changes, each of our three main functions takes in a list of jobs. We should keep things flexible so that we could create test_jobs_two and run it thru all functions and get different results.

@TravisBuddy
Copy link

Hey @Mohitkumar6122,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: d78a7b90-ffd7-11ea-9882-0125ab0f75bf

@Mohitkumar6122
Copy link
Author

Create a Job class

I hope these changes help to clarify...

I have rearranged the code in a way that will BREAK THE TESTS. I make this clearer, we will have a Job class and will remove the Schedule class and replace it with functions. Let's keep the Job class super simple. Its only goal is to carry around the deadline and profit for each Job so that we no longer move around separate lists of ints.

With these changes, each of our three main functions takes in a list of jobs. We should keep things flexible so that we could create test_jobs_two and run it thru all functions and get different results.

your changes made code super easy and understandable but problem is that it isn't running any more 😟

@cclauss
Copy link
Member

cclauss commented Sep 26, 2020

problem is that it isn't running anymore

Yes... I do not understand the algorithm so you will have to make it work again with the Jobs class and the function signatures that I provided.

@Mohitkumar6122
Copy link
Author

problem is that it isn't running anymore

Yes... I do not understand the algorithm so you will have to make it work again with the Jobs class and the function signatures that I provided.

sure i will work on it ASAP but my exams are coming so maybe i will start working on it after 2 weeks 😄

@spamegg1
Copy link
Contributor

spamegg1 commented Sep 27, 2020 •

1 E302 expected 2 blank lines, found 1
1 E305 expected 2 blank lines after class or function definition, found 1
54 F821 undefined name 'self'

The trouble starts with the schedule function on line 49 and continues all the way down.
It seems like the functions schedule and is_feasible were meant to be class methods?
However I don't see self.x, self.j or self.k included in the constructor method of Job.
I guess those were left over from the earlier Schedule class?
If the two functions were NOT meant to be class methods for Job they need to be rewritten completely, with any references to self removed.

@cclauss
Copy link
Member

cclauss commented Sep 27, 2020

Yes @spamegg1 that was already discussed in the comments above.

@cclauss cclauss marked this pull request as draft September 27, 2020 13:46
@stale
Copy link

stale bot commented Nov 21, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Nov 21, 2020
@stale
Copy link

stale bot commented Dec 9, 2020

Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

@stale stale bot closed this Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Used to mark an issue or pull request stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants