Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Is there some reason for creating this many kumites?
Do you have a problem with some functionality, or something does not work for you? Do you need any assistance?
n=10000000019
this solution: 21.4 ms ± 587 µs
faster version: 13.4 ms ± 40.5 µs
★Faster version:
You might wanna try again, It wont work for n <= 1 and n == 4
yea, I changed the while to a for loop and the 6k one is faster almost always but the time difference is still in the same range and fluctuates wildly. I never realized that while loops are slower than for loops in python, ty for letting me know
you're comparing a while loop and a for one. In python, they behave differently about the perfs (while is slower) => those checks are meaningless in the current state.
also I have no idea why my reply got posted twice
hmm, the results of comparing the two often turns out to be wildly inconsistent in time difference but remains in the 1-10µs range, tho I found that the n = 19 and 1009 takes longer with 2k, n = 10000000019 takes less with the 2k one most of the time. Code used for testing:
hmm, the results of comparing the two often turns out to be wildly inconsistent in time difference but remains in the 1-10µs range, tho I found that the n = 19 and 1009 takes longer with 2k, n = 10000000019 takes less with the 2k one most of the time. Code used for testing:
Your solution is 2k optimization (only ignores multiples of 2).
My first solution is 6k optimization (ignores multiples of 2 and 3).
And last solution is 30k optimization (ignores multiples of 2, 3 and 5) — but in this solution, the constant is larger. Therefore, further I compare only 2k and 6k optimizations.
n = 19 (is prime)
n = 1009 (is prime)
n = 10000000019 (is prime)
You can also just use more arguments of the range function, probably faster because it should be implemented in C.
https://docs.codewars.com/references/markdown/extensions/#math-typesetting
This may be of use to you.
No random tests (at least in python).
https://docs.codewars.com/authoring/guidelines/submission-tests/#random-tests
Duplicate.
Is latex an option in the markdown?