Skip to content

Add edge case to handle negative rod length in RodCutting algorithm #5904

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

Merged
merged 8 commits into from
Oct 22, 2024

Conversation

Chiefpatwal
Copy link
Contributor

@Chiefpatwal Chiefpatwal commented Oct 19, 2024

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.88%. Comparing base (69a1424) to head (7478547).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #5904   +/-   ##
=========================================
  Coverage     66.88%   66.88%           
- Complexity     4516     4517    +1     
=========================================
  Files           613      613           
  Lines         16994    16996    +2     
  Branches       3281     3282    +1     
=========================================
+ Hits          11366    11368    +2     
  Misses         5181     5181           
  Partials        447      447           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Chiefpatwal
Copy link
Contributor Author

I’ve made some updates to the RodCutting algorithm to handle an edge case where the length of the rod is negative. Previously, the code didn’t account for this situation, which could lead to unexpected behavior.

Now, I’ve added an IllegalArgumentException to ensure that if a negative rod length is passed, it throws a clear error message, preventing any further calculations. This change should enhance the robustness of the algorithm.

Additionally, I've implemented a test case for this scenario, and it’s working correctly to validate the expected behavior.

@Chiefpatwal Chiefpatwal marked this pull request as ready for review October 19, 2024 17:43
@siriak siriak enabled auto-merge (squash) October 22, 2024 17:47
@siriak siriak merged commit efb16c1 into TheAlgorithms:master Oct 22, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants