Ad
  • Default User Avatar

    Resolvsed with actual random location tests.

  • Default User Avatar

    Please could you run again to confirm that the issue has been dealt with?

    I have removed the original test that used a bad randomising method. I have also implemented a new shape which is very large (111 a bit big I know but I will change kata description to match). This one makes use of completely random coordinates to test again as I cannot think of how to nicely and efficiently generate random shapes which do not overlap at this moment in time. I am sure if needed I can implement it, but for now it should be fine.

  • Default User Avatar

    I will ensure that the tests are random. Thank you for making me aware.

  • Default User Avatar
  • 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.

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

  • Default User Avatar

    For 42 pieces you have 3 options since we are not including side length 1:
    2 * 21
    this option gives 0 inner pieces since every piece has a flat side. Therefore inner - outer = -42 . . .
    3 * 14
    This time the inner pieces are 1 * 12 which is 12. Total outer pieces are 30. so inner - outer = -18
    6 * 7 . . .
    there are 4 * 5 inner pieces for 20 inner and thus 22 outer pieces. 20 - 22 = -2
    Most negative difference is -42 and most positive difference is -2 as it is the most positive of all of the options. Hope that helps.

  • Default User Avatar

    This issue should now be fixed with the tests, but if I still have it incorrect and your solution is giving you difficulty just reply and I will get on it ASAP.

  • Default User Avatar

    This kata is about calculating the most negative possible difference between the number of outer pieces of a jigsaw and the inner most pieces of a jigsaw as well as the most positive. Since for example a 42 piece jigsaw can have four sets of dimensions (3 x 7, 2 x 21, 6 x 7 or 1 x 42). It just asks what is the greatest possible difference in both the negative and positive sense.
    In other words, what is the smallest number of inner pieces to greatest number of outer pieces for most negative.
    What is the greatest number of inner pieces to smallest number of outer pieces for most post positive.
    I will add images (soon) to help explain in instructions.

  • Default User Avatar

    Problem acknowledged. I am now looking into the cause and a solution will be found in the next hour.
    Edit: Problem is in original solution, code section:
    // Second the most postive will be when the sides are matching in length most closely

    let firstSide = 1;
    let secondSide = 1;
    for (let i = decompositionPrimes.length - 1 ; i >= 0 ; i--){
    if (firstSide > secondSide){
    secondSide *= decompositionPrimes[i];
    } else {
    firstSide *= decompositionPrimes[i];
    }
    }

    I am currently looking at solving this issue.

  • Default User Avatar

    Random testing should have removed this as an issue. If I am incorrect please tell do tell me.

  • Default User Avatar

    Thank you. I will edit to be randomised tests.