-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Improve Project Euler problem 058 solution 1 #4782
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
Improve Project Euler problem 058 solution 1 #4782
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes the prime checker and uses isqrt. Tested both solutions with timeit with a milion iterations testing numbers from 0 to 100. I tested only the isprime function.
Base was 7.2938464519999995 the changed version in the pull request was 6.3931597710000005.
For checking numbers 0 to 1000, same set up I got: 72.098172718s old and 95.55209983499999 ne.
5804a98
to
72407e2
Compare
@chakeson Do you want to say that my improvement is slower for numbers 0 to 1000 and faster for numbers from 0 to 100? Please check these tests once more time. In my opinion, the greater number, the faster improvement (over base) P.S. You approved pr, but you are not authorized to merge it? |
00ffded
to
72407e2
Compare
It's testing 10x the size so I would expect it to be around 10x the time, but the speed up for 1000 is faster then the speed up for 100. For 100 its 12% faster for 1000 its 24% faster. |
@poyea @l3str4nge please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your pull request!🤩
Describe your change:
Improve Project Euler problem 058 solution 1 - the top 7 slowest solution on Travis CI logs (under
slowest 10 durations
:11.38s call scripts/validate_solutions.py::test_project_euler[problem_058/sol1.py]
):Fix typo
Improve solution (locally 4+ times - from 8+ seconds to ~2 seconds)
Add an algorithm?
Fix a bug or typo in an existing algorithm?
Documentation change?
Checklist:
Fixes: #{$ISSUE_NO}
.