Ad
  • Custom User Avatar

    0.09 is a random value to estimate the maximum range to check upon, i.e, no mathematical reasoning behind it.

    Also, your code would check all number of (2^53-1) * 0.09 which is equivalent to 8.10647932927E+14 down to 0 and doing exponentation on such Big Integers would inevitably cause overflow, if not execution time out.

    You should find a mathematical threshold to stop looping (early exit) or just research on some properties of perfect powers. ^^

  • Custom User Avatar

    yeah, that's a good point.
    I've started to comment my code and even leave in console.logs.
    The reason I left them out was to get the code as succinct as possible, but that's just for pride.

  • Custom User Avatar

    You have to run all tests in 12s not only one =)

  • Default User Avatar

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

  • Default User Avatar

    Huh I guess I did it a different way than you then.

  • Default User Avatar

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

  • Custom User Avatar
  • Default User Avatar

    The hard part of this for me was finding the solution to the math problem. Once you have it the code wasn't all that complex. Very fun Kata! To anyone struggling I would say to look into the math bits. I didn't find the supplied article all that helpful IMO.

  • Custom User Avatar

    if a number is a perfect power, return any pair that proves it.

    Your code should only return a single pair.

  • Default User Avatar

    When I call this function with 531441 then run the program with node inside of a terminal I get.

    [ [ 729, 2 ], [ 81, 3 ], [ 27, 4 ], [ 9, 6 ] ]
    
  • Custom User Avatar

    Are you returning only one pair?

  • Default User Avatar

    I did this kata using JS.
    My code doesn't time out most of the times when I try it now however I got this error message which is confusing to me because they are valid pairs.

    Unhandled rejection TestError: your pair (729,2, 81,3) doesn't work for 531441 - Expected: 531441, instead got: NaN
    

    If you try both of these pairs in a calculator they come out to 531441. I think therefore there must be something wrong with the tests on the site? If someone could give me some insight here I would appreciate it.

  • Default User Avatar

    Yeah I am having same issue. I can get like 50 mill to go through but get this time out nonsence. My code looks pretty clean too.

  • Custom User Avatar

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

  • Default User Avatar

    Why does nobody comment their code on here? I feel that defeats the whole purpose of reading over the code to learn new stuff. A comment like 45 is the sum of every number 1-9 would be helpful right off the bat. What confuses me is how does this compare all the possibilities of every Sudoku grid? What do sumh and sumv represent? It looks like osums represents 1 sudoku 9x9 grig but with no comments unless you throw the code into an editor and play around with it who knows?

  • Loading more items...