Ad
  • Custom User Avatar

    If you have execution timeout, then the solution does not pass, despite of returning correct answers.

    See if this paragraph helps.

  • Default User Avatar

    My solution passed tests, but Execution Timed Out (12000 ms). I used BigInt in the loop for big calculations. What should i do?

  • Default User Avatar

    did not understand your hint and have used AI

  • Custom User Avatar

    Object.keys doesn't work on an iterable object ( well, it does, but it doesn't do what you want it to do ). You have to iterate it. Follow the link in the description and read up on the protocol.

    This question was already answered here.

  • Default User Avatar

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

  • Custom User Avatar
                   v                           v   v
    expected [ 9, +0, 9, 1, 2, 1, 1, 3, 1, 9, +0, +0, 9, +0, +0, +0, +0, +0, +0, +0 ] to deeply equal 
             [ 9, 9, 1, 2, 1, 1, 3, 1, 9, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ]
    

    The first value there is your answer, and you can see there are more than one 0 not at the end. Probably you're mutating the array at the same time you run through it, skipping values.

    About what +0 is, you can see that's 0, don't mind the + before it, it's probably chai adding it in the assertion.

  • Default User Avatar

    I don't understand what is wrong
    expected [ 9, +0, 9, 1, 2, 1, 1, 3, 1, 9, +0, +0, 9, +0, +0, +0, +0, +0, +0, +0 ] to deeply equal [ 9, 9, 1, 2, 1, 1, 3, 1, 9, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ]

    +0 what is this?

  • Default User Avatar

    I solve it with using integer->string conversions, then without using integer->string conversions. But everytime a have Execution Timed Out (12000 ms)

  • Default User Avatar

    no, it returns with commas

  • Default User Avatar

    But this solution return number without "," (commas)

  • Custom User Avatar

    Resolved.

  • Default User Avatar

    Alright my thought process was incorrect. Thanks for the fast response you are 100 % correct. I did not realise i and j can be the same to solve this. That was my problem. Resolved.

  • Custom User Avatar

    I just solved the kata in JS with my solution from other languages and I have no good idea what this issue is about. Everything seems to work as expected? Broken formatting in the original post is not helpful either.

  • Custom User Avatar

    I'm not really sure I understand your issue, but it seems like a code issue to me. You can represent 4 as 2 + 1 + 1, just like you can represent 16 as 8 + 4 + 4, and 256 as 128 + 64 + 64. I guess your assumption is wrong..?

  • Default User Avatar

    According to instructions tests are invalid for 2 to the power of any number in JavaScript:

    Write a function that accepts a number, and checks it can be represented as a sum of exactly 3 powers of 2. (n == 2i + 2j + 2**k, i, j, k >= 0)

    --> Since 2 ** 0 = 1, then as far as I can tell you cannot have a value as true which is 2 ** i where i is the value that obtains the number in the test since then you still have + 1 and + 1 for + 2 extra. This needs to be dealt with since: "n = 4: expected false to equal true " is not correct nor 256 or 1024, etc <--

    For example:

    three_powers(2) # False
    three_powers(3) # True, 3 = 20 + 20 + 20
    three_powers(5) # True, 5 = 2
    0 + 21 + 21
    three_powers(15) # False
    Input
    1 <= n <= 2 ** 512 - 1
    There are 100 performance tests in languages with arbitrary precision integers, and a huge amount in C/Lua.

    Note to translators: this kata should NOT be translated into any languages without arbitrary precision integers, as the performance requirements are not guaranteed to be properly enforceable.

    If you need I can provide my code for testing purposes since the only ones it fails are the ones which are incorrectly labeled as true for 2 to the power of a single value. Just tell me how.

  • Loading more items...