Skip to content
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

fix: make interface of NCRModuloP fail-safe #2469

Merged
merged 24 commits into from
Aug 31, 2024

Conversation

vil02
Copy link
Member

@vil02 vil02 commented May 21, 2023

Description of Change

The original implementation of NCRModuloP, has two problems:

  • the member variable fac is one element too short,
  • the computation math::ncr_modulo_p::NCRModuloP(100, 43).ncr(10, 3, 13) returns 2, which is incorrect since10C3 = 120 and 120%13 = 3 (note different values of p).

This PR fixes above issues and does some minor refactoring, style improvements and adds missing test cases.

Checklist

  • Added description of change
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:
Updates to fail-safe API of NCRModuloP

math/ncr_modulo_p.cpp Show resolved Hide resolved
math/ncr_modulo_p.cpp Outdated Show resolved Hide resolved
math/ncr_modulo_p.cpp Show resolved Hide resolved
math/ncr_modulo_p.cpp Outdated Show resolved Hide resolved
math/ncr_modulo_p.cpp Outdated Show resolved Hide resolved
@vil02 vil02 requested a review from realstealthninja May 25, 2023 20:55
@Panquesito7 Panquesito7 added the bugfix Correction to existing algorithms label May 30, 2023
math/ncr_modulo_p.cpp Outdated Show resolved Hide resolved
math/ncr_modulo_p.cpp Outdated Show resolved Hide resolved
@vil02 vil02 requested a review from Panquesito7 May 30, 2023 21:37
Panquesito7
Panquesito7 previously approved these changes May 31, 2023
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks! 🚀

@Panquesito7 Panquesito7 added the Improvement improvement in previously written codes label May 31, 2023
math/ncr_modulo_p.cpp Show resolved Hide resolved
math/ncr_modulo_p.cpp Show resolved Hide resolved
@realstealthninja
Copy link
Collaborator

Please do not resolve unless you have instructions to do so or the changes are sufficiently discussed

@vil02 vil02 requested a review from Panquesito7 June 23, 2023 21:25
@vil02
Copy link
Member Author

vil02 commented Jul 13, 2023

@Panquesito7 could you please have a final look?

math/ncr_modulo_p.cpp Outdated Show resolved Hide resolved
math/ncr_modulo_p.cpp Show resolved Hide resolved
@vil02
Copy link
Member Author

vil02 commented Sep 8, 2023

@Panquesito7, @realstealthninja could you please have a final look?

Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me ❤️

@vil02 vil02 force-pushed the bug_in_ncr_modulo_p_patch branch from 1635eda to a928ddc Compare October 2, 2023 11:51
Copy link
Contributor

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

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Dec 27, 2023
@vil02
Copy link
Member Author

vil02 commented Dec 27, 2023

@Panquesito7, @realstealthninja please dont-close.

@github-actions github-actions bot removed the stale Author has not responded to the comments for over 2 weeks label Dec 28, 2023
@vil02 vil02 force-pushed the bug_in_ncr_modulo_p_patch branch from a928ddc to fb3fd9c Compare January 16, 2024 07:13
@vil02 vil02 force-pushed the bug_in_ncr_modulo_p_patch branch from fb3fd9c to d44c270 Compare February 12, 2024 21:23
@realstealthninja realstealthninja added the dont-close This issue/pull request shouldn't be closed label Feb 13, 2024
@realstealthninja realstealthninja merged commit af72fab into TheAlgorithms:master Aug 31, 2024
6 checks passed
@vil02 vil02 deleted the bug_in_ncr_modulo_p_patch branch August 31, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Correction to existing algorithms dont-close This issue/pull request shouldn't be closed Improvement improvement in previously written codes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants