-
Notifications
You must be signed in to change notification settings - Fork 5k
Egg Drop Dynamic Problem #400
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
Conversation
More dynamic programming algorithms would be nice. If you take a look at the repository's pull request list, you can see a contribution for another dynamic programming algorithm which looks at the Knapsack problem.
I have a few comments at this point:
- To be accepted into the repository, all contributions should have a
READMEfile. As a reader, I'd want to know what problem this algorithm solves, and in general terms how it solves it. - At the moment, sorry to say, this code wouldn't be accepted, because it doesn't compile. I don't know the egg-drop algorithm very well (see point 1) so I don't know how I'd correct it.
- The code itself needs to make its intention clearer. This would make it easier to read, easier to understand, perhaps easier to correct, and might help you write the
READMEas well.
For example: why iseggFloor[2][1]given a value of 1? What do the indicesi,jandkrepresent? What's the significance of settingeggFloor[i][j]to1000000? In particular, consider the edge-cases - would this algorithm still work correctly if theeggDropfunction were called and there was only 1 floor, or if there were 1000001 floors?
Use meaningful names; name your magic numbers; break complicated functions (e.g. the current line 17) into smaller, easier-to-digest steps; consider using optionals to represent situations where you don't yet know the value. - Provide some examples of the
eggDropfunction - ideally at the end of a playground file and in unit tests. For example, if I wroteeggDrop(5, numberOfFloors: 3)in my code, what value would I expect it to return to show that it was working correctly?
I hope that's fair criticism and doesn't discourage you. I look forward to seeing your revised contribution.
@aarkalyk Still up for this?
@narrativium Thanks for the feedback! I'll take into account all your suggestions and submit my contribution in a few days.
@kelvinlauKL Yup!
@narrativium @kelvinlauKL Please, review my pull request.
Thanks!
@aarkalyk Sorry for the wait. Going to merge this and add a few bits of polish 👍. This PR has been collecting dust long enough!
Hello!
I noticed that there aren't many dynamic programming algorithms in the repository, so I decided to contribute to the project by adding one of the most famous problems in dynamic programming "Egg Drop Problem". I'd appreciate if you could look through my code and give some feedbacks.
Thanks in advance for your attention!