Skip to content

maths/number_of_digits.py is naive! #2220

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

Closed
vasugamdha opened this issue Jul 21, 2020 · 2 comments · Fixed by #2221
Closed

maths/number_of_digits.py is naive! #2220

vasugamdha opened this issue Jul 21, 2020 · 2 comments · Fixed by #2221

Comments

@vasugamdha
Copy link
Contributor

maths/number_of_digits.py has a naive method. The suggested method has a time complexity of O(n). We can count number of digits of a number in O(1).

@cclauss
Copy link
Member

cclauss commented Jul 21, 2020

Can we put both algorithms into the same file and add a benchmark that proves that the theoretical performance improvement is achieved and that the proposed algorithm is noticeably faster than the current algorithm?

@vasugamdha
Copy link
Contributor Author

@cclauss Yes! I have proposed the algorithm that is noticeably faster as num_digits_fast() in the #2221
Please review it. Thanks.

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 a pull request may close this issue.

2 participants