Update count_number_of_one_bits.py#7589
Conversation
removed the modulo operator as it is very time consuming in comparison to the and operator
|
Please add a timeit (or similar) benchmark to prove that the proposed code is faster than the original code. |
Updated with the timeit library to compare. Moreover I have updated my code which helps us in reaching the output comparatively faster.
for more information, see https://pre-commit.ci
|
I have updated my code. It would be great if you could have a look into it. |
Co-authored-by: Christian Clauss <cclauss@me.com>
|
I have updated the code as suggested. |
|
Please run this on your own machine. The doctest fails. |
Updated the code
|
I am extremely sorry for the silly mistakes. Please could you check it now |
|
Would it be more self-documenting to change the variable Let's make |
|
I guess the variable name "number" is more appropriate as it's representing the number which the user will be providing as the input and not the bit_length. |
Updated code
for more information, see https://pre-commit.ci
cclauss
left a comment
There was a problem hiding this comment.
Awesome contribution. Thanks for doing this!!
for more information, see https://pre-commit.ci
|
Hi could you please add a label of hacktoberfest-accepted. |
|
Thank you. |
removed the modulo operator as it is very time consuming in comparison to the and operator
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.