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.
:)
This will fail if arr contains any NA or NaN elements.
Thank you!
About the how: when the loop has only one line inside you can omit the curly braces, it's not so clear but if you're careful with indentation it can be read too. As the why, I don't have your answer, maybe the OP can answer that one.
Can someone explain to me how and why OP choose to omit the curly braces at the end of the for loop statement?
Amazing! Thanks very much for the explanation
GISTS
list is very particular: each key is a power of 2.If you think in binary representation, each key is tied to one particular bit, then each gift corresponds to this very bit.
Take the binary representation of a number
n
and look at each of its turned on bit (1
).It gives you a list of gifts as one bit matches one gift.
Finally all you need to do is to sort the answer to output an alphabetically sorted list.
Is it more understandable now?
how does this work? I am confused by the if statement. Why do you not need to match the toy key to the number and then reduce the number by the amount of the key?
Thanks Alyona42