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.
IKR. Got confused by a sec reading the code.
I guess because the return type of countBits is set to size_t
This comment is hidden because it contains spoiler information about the solution
Yes, but no.
Please use decimal "ones" or "zeros" when counting in decimal - binary "ones" and "zeros", though technically the same, don't like it very much to be misgendered that way - because they identify as binary :D
Thats so nice and clean - tried similar, but didn't knew you could use a for-loop as a lazy while-loop like that and I
also wasn't sure if bitshift-equals is a legal expression.
why the use of
size_t
insead ofunsigned
?== 0 is false
< 0 is true ?
how the loop stops when value == 0? can you explain?
your func is called
is_odd
but thats ais_even
func 😂 wtfmany probs
I made such a dreadful solution in comparison to this one
don't we need to free the memory at some point after we use it ?
I don't see it either, but since the code uses the nonstandard function strrev(), it's automatically non-portable even without plusDot().
may i know where does
plusDot
come from?Your code has a bug.
Let say g=3, m=3, n=4
Result: [0, 3] // Should be[0,0]
Let say g=5, m=5, n=6
Resutl: [0,6] // Should be [0,0]
Your function will getting problem when g=m and n > m + 1 (or more)
Your problem code is here:
if (candidates[1] - candidates[0] == (long long)g) {
return candidates;
For the first iteration
candidate[1] will fill with first prime number
but candidate[0] is 0.
So, when first prime - 0 == g (your code wrong here)
// you should start compare candidate[0] and candidate[1] after these two values are filled
Loading more items...