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.
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
I do not find this code "Best Practices" or "Clever". There are two bugs in the solution.
Bug 1: Deadlock
With some input values variable v will overflow, become negative and the while loop will go in deadlock.
Test with the max value for a 64-bit integer.
testequal(9223372036854775807, -1);
Bug 2: Precision loss with double conversion
The inputs to pow function are converted to double and the output is converted back to integer. A double can't represent whole numbers bigger than 2^53.
Test with the maximum number of squares possible for an 64-bit integer.
testequal(9223193340756366400, 77935);
may anyone explain the code started from
b += c > 1
? I don't understand whyc
, which is index, is added to pointerb
. This expression will give value of b after assigning, which must be > 1. Also, will this update pointerb
and left some memory unused?Besides, as a terminating null character is automatically appended after the content written in
snprintf
, how can the code solve this problem?Cool to update pointer b with snprintf!
Loading more items...