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.
Approved some time ago
Can someone accept this? All issues are resolved...
There are few places, where CPU cycles are totally wasted.
prime_factors
are executed for each element of the array twiceprime_factors
you don't need to count all factors - ifcnt
is greater thenk
, you can stop searching.And repeated random test also added...
Random tests. (in a loop.) Prefferably 100 of them.
Well, you make a loop for 100 tests, generate a random number, and test the user's solution with it.
Headers added.
@Steffan153 - 50 of what? Repeats?
I completely don't get the approach to random tests at codewars. IMHO it would be best to have fixed RNG seed and some number of randomized test cases - so they are random(ized) but repeatable. (On my other solution, I was pointed, that fixed RNG seed is bad, because it's not random that way...).
IMHO random test cases should test how the solution works on bigger dataset, that can't be easily hardcoded. All the corner/edge cases should be tested in normal tests.
I see what @Steffan153 means now. It's definitely better to include whatever is used explicitly.
For example, the reference solution happens to work without including any of them, but it might break any time if something changes internally (like test framework). Same thing for the tests. It should include anything it uses even if it currently works.
Also, it doesn't obfuscate the code at all.
It looks like it does work without
<algorithm>
.@Steffan153, can you explain why it's needed? Does anything in test uses it?
Does it continue to compile even if the solution removes the header? Tests should include whatever it requires independent from the solution.
We need to consider the case where users come up with different ways to solve and removes unnecessary headers for their solution.
How is it pointless? All random tests should have at least 50
Because it's bad practice...
And regarding headers - everything compiles and executes correctly - why should I add headers that are technically unnecessary and only obfuscate the source code?
Original task has no random tests.
TBH there is no reason for more random tests - they will be basically the same. I can loop to test more than one strings, but it seems pointless for me.
Only 1 random test????
Sample tests and tests need headers for
std::pair
,char
,size_t
, andstd::vector
.Tests need header
<algorithm>
, I think.Thanks for review.
Fixed all issues.
Original task (Rust translation) has no random tests, but I added them for C++.
Loading more items...