Skip to content

Python program for Carmicheal Number #6864

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 9 commits into from
Oct 12, 2022

Conversation

Roy-Shubhajit
Copy link
Contributor

@Roy-Shubhajit Roy-Shubhajit commented Oct 9, 2022

Describe your change:

Added Python Program for checking whether a number is Carmicheal number or not.

  • 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}.

@algorithms-keeper algorithms-keeper bot added require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html labels Oct 9, 2022
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 9, 2022
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@cclauss
Copy link
Member

cclauss commented Oct 9, 2022

maths/carmichael_number.py:3:89: E501 line too long (104 > 88 characters)
maths/carmichael_number.py:48:89: E501 line too long (89 > 88 characters)

@algorithms-keeper algorithms-keeper bot removed require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html labels Oct 9, 2022
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 9, 2022
@algorithms-keeper algorithms-keeper bot added require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required labels Oct 9, 2022
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 9, 2022
@Roy-Shubhajit Roy-Shubhajit requested review from cclauss and removed request for Kush1101 October 9, 2022 09:53
@Roy-Shubhajit
Copy link
Contributor Author

Hey @cclauss, can you please review this pull request for Hacktoberfest.

Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

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

Please write doctests for your functions

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

"""


def gcd(a: int, b: int) -> int:

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file maths/carmichael_number.py, please provide doctest for the function gcd

Please provide descriptive name for the parameter: a

Please provide descriptive name for the parameter: b

return gcd(b, a % b)


def power(x: int, y: int, mod: int) -> int:

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file maths/carmichael_number.py, please provide doctest for the function power

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

return temp


def isCarmichaelNumber(n: int) -> bool:

Choose a reason for hiding this comment

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

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: isCarmichaelNumber

As there is no test file in this pull request nor any test function or class in the file maths/carmichael_number.py, please provide doctest for the function isCarmichaelNumber

Please provide descriptive name for the parameter: n

@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 12, 2022
@cclauss cclauss added hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest labels Oct 12, 2022
@cclauss cclauss merged commit f0d1a42 into TheAlgorithms:master Oct 12, 2022
@CaedenPH
Copy link
Contributor

@cclauss
Why have you merged this commit? It didn't even pass the CONTRIBUTING guidelines such as snake_case naming conventions and informative parameter names

@cclauss
Copy link
Member

cclauss commented Oct 12, 2022

Yes. I saw that as I pressed the Merge button. If you open a PR to fix that then I will merge it.

@cclauss
Copy link
Member

cclauss commented Oct 12, 2022

In fact, we should probably add a good flake8 naming plugin to pre-commit so that our tests fail on bad names.

Your thoughts?

@CaedenPH
Copy link
Contributor

In fact, we should probably add a good flake8 naming plugin to pre-commit so that our tests fail on bad names.

Your thoughts?

Sounds like a good idea

@cclauss
Copy link
Member

cclauss commented Oct 12, 2022

Do you have pre-commit running on your local machine?

Would you be willing to make the following one-line change to .pre-commit-config.yaml and then fix the files that will be flagged by running pre-commit run --all-files? It is a bit of busy-work that will take some time but it will be a nice improvement to our project.

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0abe647..2f6a928 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -40,6 +40,7 @@ repos:
           - --ignore=E203,W503
           - --max-complexity=25
           - --max-line-length=88
+        additional_dependencies: [pep8-naming]

   - repo: https://github.com/pre-commit/mirrors-mypy
     rev: v0.982

@CaedenPH
Copy link
Contributor

Do you have pre-commit running on your local machine?

Would you be willing to make the following one-line change to .pre-commit-config.yaml and then fix the files that will be flagged by running pre-commit run --all-files? It is a bit of busy-work that will take some time but it will be a nice improvement to our project.

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0abe647..2f6a928 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -40,6 +40,7 @@ repos:
           - --ignore=E203,W503
           - --max-complexity=25
           - --max-line-length=88
+        additional_dependencies: [pep8-naming]

   - repo: https://github.com/pre-commit/mirrors-mypy
     rev: v0.982

Unfortunately I am not at home currently, but I can do it in a couple hours when I return

@cclauss
Copy link
Member

cclauss commented Oct 12, 2022

No rush!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants