Skip to content

add reverse_bits.py #4120

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 5 commits into from
Jan 27, 2021
Merged

Conversation

ayushbisht2001
Copy link
Contributor

Describe your change:

I have added an algorithm which reversed the bits of any 32 bit interger .

  • Add an algorithm?

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

@ghost ghost added require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required awaiting reviews This PR is ready to be reviewed labels Jan 14, 2021
Copy link

@ghost ghost 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.

@@ -0,0 +1,67 @@
def get_reverse_bit_string(bn : int) -> str:
Copy link

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 bit_manipulation/reverse_bits.py, please provide doctest for the function get_reverse_bit_string

return bit_string


def reverse_bit(n: int) -> str:
Copy link

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: n

@ayushbisht2001
Copy link
Contributor Author

@algorithms-keeper review-all

@ghost ghost added tests are failing Do not merge until tests pass and removed require descriptive names This PR needs descriptive function and/or variable names labels Jan 14, 2021
Copy link

@ghost ghost 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

@ghost ghost 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.

@@ -0,0 +1,67 @@
def get_reverse_bit_string(num_reversed : int) -> str:
Copy link

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 bit_manipulation/reverse_bits.py, please provide doctest for the function get_reverse_bit_string

@ayushbisht2001
Copy link
Contributor Author

@algorithms-keeper review

@ghost ghost removed the require tests Tests [doctest/unittest/pytest] are required label Jan 14, 2021
@ayushbisht2001
Copy link
Contributor Author

@algorithms-keeper review

@ayushbisht2001
Copy link
Contributor Author

Why some of the checks are failing?? .. I didn't get, why is it happening..

@ayushbisht2001
Copy link
Contributor Author

@algorithms-keeper review-all

@ayushbisht2001
Copy link
Contributor Author

@xcodz-dot , hey can u please help me ..... what's wrong with my PR. Will u please review it .

@amaank404
Copy link
Contributor

amaank404 commented Jan 16, 2021

spelling mistakes

bit_manipulation/reverse_bits.py:3: interger ==> integer
bit_manipulation/reverse_bits.py:73: shif ==> shift

code format (run the below commands at root of repo after fixing the spelling mistakes)

pip install pre-commit
pre-commit run -a #(This might show that it has error but this has fixed all the format issues, you can rerun it for your convenience)

then upload the changes

@amaank404
Copy link
Contributor

@algorithms-keeper review

this progress is automatic and runs on every commit or changes you make so you do not need to run this command again and again.

@ayushbisht2001
Copy link
Contributor Author

Capture

@xcodz-dot , I have tried everything which u suggest me , but withal some checks are still failing. Kindly please help me,... how to resolve all these errors.

@amaank404
Copy link
Contributor

Capture

@xcodz-dot , I have tried everything which u suggest me , but withal some checks are still failing. Kindly please help me,... how to resolve all these errors.

do not worry about those errors, just commit and upload the local changes made by that

@ghost ghost added require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required labels Jan 17, 2021
Copy link

@ghost ghost 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.

# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm


def binary_xor(a: int, b: int) -> str:
Copy link

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: a

Please provide descriptive name for the parameter: b

@@ -0,0 +1,67 @@
def get_reverse_bit_string(bn : int) -> str:
Copy link

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 bit_manipulation/reverse_bits.py, please provide doctest for the function get_reverse_bit_string

return bit_string


def reverse_bit(n: int) -> str:
Copy link

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: n

@amaank404
Copy link
Contributor

Ok let me do this here, i will fix all the errors in a while now

@ayushbisht2001
Copy link
Contributor Author

Thank you @xcodz-dot

@amaank404
Copy link
Contributor

Oh and you will have to remove one of the files as only 1 file per PR is allowed, to submit the second file create a new PR after this one gets accepted. Until then keep the second file somewhere on your local machine

Copy link

@ghost ghost 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.

@@ -0,0 +1,67 @@
def get_reverse_bit_string(bn : int) -> str:
Copy link

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 bit_manipulation/reverse_bits.py, please provide doctest for the function get_reverse_bit_string

return bit_string


def reverse_bit(n: int) -> str:
Copy link

Choose a reason for hiding this comment

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

Please provide descriptive name for the parameter: n

@ayushbisht2001
Copy link
Contributor Author

@xcodz-dot , Now, is it good to go?

@amaank404
Copy link
Contributor

yes, please wait for now

@amaank404
Copy link
Contributor

ayushbisht2001#1

fix all the issues with pre-commit and algorithms-keeper bot
@ghost ghost removed require descriptive names This PR needs descriptive function and/or variable names require tests Tests [doctest/unittest/pytest] are required tests are failing Do not merge until tests pass labels Jan 17, 2021
@ayushbisht2001
Copy link
Contributor Author

@xcodz-dot, please review my PR. Is everything alright in this PR, have I not made this upto code standard??

Copy link
Contributor

@amaank404 amaank404 left a comment

Choose a reason for hiding this comment

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

I am not a maintainer here so my review doesn't do much. i will leave the merging part for @dhruvmanila and @cclauss

@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Jan 27, 2021
@AnupKumarPanwar AnupKumarPanwar merged commit 3f1e376 into TheAlgorithms:master Jan 27, 2021
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this pull request Apr 1, 2021
* add reverse_bits.py

* check

* Delete binary_xor_operator_new.py

* Fix All the errors

Co-authored-by: xcodz-dot <[email protected]>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* add reverse_bits.py

* check

* Delete binary_xor_operator_new.py

* Fix All the errors

Co-authored-by: xcodz-dot <[email protected]>
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* add reverse_bits.py

* check

* Delete binary_xor_operator_new.py

* Fix All the errors

Co-authored-by: xcodz-dot <[email protected]>
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