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 agree Clever flag is more appropriate. But this shows again that Best Practise and Clever don't mean that much. Perhaps a single Upvote button is better.
I disagree. Using a system function to cast the number to string, when bit operations can be used to determine if a bit is set (which is the whole purpose of these operators), is using a rocket launcher to me. The count operation additionally has to view every element.
Bitwise checks are mostly done, where performance has to be considered. This is why I disagree on this solution being best practice for this particular task.
Besides, if you'd found this line of code, without the method name, most folks would still not recognize that it counts bits.
Don't get me entirely wrong, I still think this solution is creative, since is solves the task with minimal effort. I just can't agree on this being best practice.
This is not less rocket launcher than your solution (and not really more than any other one).
I'm not sure why so many think this is elegant and considered to be a best practice.
You should not shoot with rocket launchers at birds.
This comment is hidden because it contains spoiler information about the solution