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.
Would someone help me understand some things about this solution?
First of all, line one capitalizes the title, then map is called over every word of the capitalized version. Then minor_words.downcase.split.include? is passed in 'a' as a parameter. As I understand, 'a' is an element of the capitalized words array, which means it's capitalized. If we compare it to a downcased version then it will never be incuded! Right?
Then what about the exception in the instructions? The first word of the title is supposed to be capitalized no matter what. In this case, it doesn't seem to matter which word it is, I see no check whatsoever regarding the first word of the title.
This depends a lot on the definition of "power of two" you establish. We could be allowing rational exponents (square roots). Even Integer exponents would start a painful process as 2^(-2) (1/4) would be a valid parameter. With the same rules we could say that exponents are only Natural, then 1 would not be a power of two.
I take your point and very much agree that we should definitely define the Range of exponents we are taking into account.
I'd not vote that solution as a Best Practice. It is a clever one though. I also think that this is more of a javascript problem than a solution problem. Use of & is discouraged but it shouldn't be. & is one of the most basic operators. Not being able to '&' is like not being able to sum. Javascript is making a complex operation out of a very basic one. I really don't think we should worry about using '&', mainly because I wouldn't re-adapt my code because of such a major flaw in the language. Anyway, the top voted solution remains the most performant one. It is at most a two-step operation. Calculations of logarithms, uses of toString or to_str and loops are at least linear timed algorithms compared to a constant time one.