Ad
  • Default User Avatar

    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.

  • Default User Avatar

    Simple, elegant - the entire reason I use codewars is to be enlightened by such answers!

  • Default User Avatar

    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.

  • Default User Avatar

    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.

  • Default User Avatar

    The description should warn the user against trying permutation, to avoid unnecessary frustration!

  • Default User Avatar

    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...)

  • Default User Avatar

    This solution is incorrect - this returns true if x = 1!

  • Default User Avatar

    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!

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution