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.
So that time complexity is O(n) instead of O(n log n) which seems to be what most people have done. IMHO, the test cases weren't rigorous enough to force people to take the more optimal route.
Simple, elegant - the entire reason I use codewars is to be enlightened by such answers!
It would be great if either of you could post a comparison using the ruby benchmark module - It'd be interesting to see if Ruby optimizes the code, so that it performs better than the theoretical bound.
You are right - I don't know why I posted that! Maybe I was implicitly thinking that all powers of 2 had to be even, and having a 1 as the last bit changed that.
The description should warn the user against trying permutation, to avoid unnecessary frustration!
The test cases should check for false positives for numbers other than those with leading '11' in their binary representation. The current test cases allow incorrect solutions to be accepted (for instance, the solution x.to_s(2).count('1') == 1 is accepted even though its wrong (reports 1 as a power of 2...)
This solution is incorrect - this returns true if x = 1!
The description should mention that words should be returned in the same order that they were present in the original sentence. Mine didn't, but I fixed it with a hack which worked - the test cases need to be updated to handle that!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution