Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • Are you changing the initial input?

  • Im getting this same error message. "return.replace is not a function"
    I havent used anything called .replace so I dont think this is in my code.

    I really like this Kata though, its got my brain going! I just cant seem to move past where Im at because I like to test as I go and it wont let me do anything past this due to this error message.

  • It's saying you're trying to use "replace" on an undefined variable. Look for where you're trying to use "replace," and make sure that you've defined the variable above that line and within its scope.

  • lol. No random testcases =P

  • I'm not sure if this is what you're describing, but it sounds similar to a problem I had where I was trying to find subsequences when the question is really asking for substrings (it says find the largest sequence, which is a little misleading). For instance, if you have the number 957923992590, this has five 9's, and indeed the largest number that is a subsequence of these digits is 99999. However, the solution actually needs the largest substring (number formed by consecutive digits) from the number, which in this case would be 99259. Hopefully that answers your question.

  • OK, I'm glad to see that you've fixed these problem.
    Republish a solution and vote/rank to it ;-)

  • Fixed, thanks.

  • Sorry to have upset you..? I do have a solution that works (I do have to validate it after all) so I'll just put that in.

  • n=32761
    ✘  Expected: 32768, instead got: 32761
    

    Very kidding ;-)

  • For posterity:

      it("random tests", () => {
        for(let i = 0; i < 20; i++) {
          let rand1 = Math.floor(Math.random() * 10 + 5);
          let rand2 = Math.floor(Math.random() * 30 / rand1 + 4);
          Test.assertEquals(closestPower(Math.pow(rand1,rand2) + Math.floor((Math.random() - 0.5) * 15)),Math.pow(rand1,rand2));
        }
      });
    
  • JavaScript: reference solution in random tests is incorrect!

    n = 32762, 32763, 32764:
    ✘ Expected: 32768, instead got: 32761
    
    n = 3131, 3132:
    ✘ Expected: 3125, instead got: 3136
    

    This doesn't show up very often .. wait. Wait. WAIT.

    There is no reference implementation.

    You just throw some random numbers in the air, catch some that are close, and compare valid solutions to that.

    This has to be the most vile, invalid approximate abomination since JavaScript started doing big integer arithmetic.

    I shall now go sit in a corner and cry. Can you at least just steal some nobler Warrior's solution and implement that in your tests?

  • Still no example tests.

  • Thanks for the heads up, it should be fixed now.

  • Thanks for the heads up. I figured having them be the exact solutions wouldn't be much of a problem, but I forgot people could then just find exact values and hard code in the pre-writtens. I've changed the random tests to not be perfect powers.

  • Loading more items...