Ad
  • Custom User Avatar

    Can't do better than linear time, constant memory. I suspect something's fishy in the tests.

  • Custom User Avatar

    Sorry, late response. You can pass a block into ls.combination(k) instead of to the .map function, which would allow you to exit early. However, the target distance is a limit, not a minimum. Since each combination you try might be higher than your last max and lower than the limit, we must visit every single combination to be sure of our answer.

    Good thinking though =D

  • Custom User Avatar

    The method name in the ruby version is "permsol", but the tests all look for a method called "permutations".

  • Custom User Avatar

    Sure, it's your kata. Sounds good to me!

  • Custom User Avatar

    Some suggestions:

    1. The method name doesn't match the one in your tests, it had to be renamed.
    2. From the description, it's not clear you should concatenate the results of each iteration. In other words, it sounds like the second test should return [3,4,5] instead of [2,3,4,2,3,4]
    3. The final tests are the same as the given ones. You should add more tests when people submit to cover every edge case.
  • Custom User Avatar

    The description could use some cleaning up. There's an abrupt cutoff after the first word, "block" is repeated one with formatting and once without, etc.

  • Custom User Avatar

    Sorry, I didn't actually mean to open an issue, CodeWars did that for me. How about "Calculating target date for compound interest"?

  • Custom User Avatar

    The title should be more descriptive.