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.
I guess because the return type of countBits is set to size_t
Thanks, this was helpful eventhough I'm a year late.
Not a best practice, for sure.
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?
Subtracting a size_t from a size_t is not well-defined when the result is negative. You should compare them first to ensure that the result is positive before subtracting them. Also, the use of the ternary operator here is just not necessary.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
many probs
I made such a dreadful solution in comparison to this one
I think it's much better to start the loop with the index 1, because you're already calculate the index 0 and 1, sorry for bad english:)
Hmmm - If you ever find yourself using 'true' or 'false' in a ternary operator statement like this, you should probably reconsider did you need to use a ternary operator in the first place ;-)
Loading more items...