Ad
  • Custom User Avatar

    were u being greedy again?

  • Custom User Avatar

    js. input data and output data
    [
    { weight: 18, price: 73 },
    { weight: 0, price: 44 },
    { weight: 13, price: 49 },
    { weight: 14, price: 26 },
    { weight: 18, price: 58 },
    { weight: 0, price: 44 },
    { weight: 16, price: 19 },
    { weight: 4, price: 92 },
    { weight: 15, price: 6 },
    { weight: 8, price: 43 },
    { weight: 0, price: 92 },
    { weight: 11, price: 80 },
    { weight: 3, price: 90 },
    { weight: 7, price: 15 },
    { weight: 11, price: 28 },
    { weight: 8, price: 53 },
    { weight: 2, price: 37 },
    { weight: 2, price: 53 },
    { weight: 7, price: 31 },
    { weight: 16, price: 9 },
    { weight: 16, price: 62 },
    { weight: 15, price: 90 },
    { weight: 2, price: 9 },
    { weight: 14, price: 30 },
    { weight: 1, price: 28 },
    { weight: 2, price: 25 },
    { weight: 15, price: 70 },
    { weight: 5, price: 7 },
    { weight: 9, price: 0 },
    { weight: 7, price: 5 },
    { weight: 3, price: 87 },
    { weight: 18, price: 96 },
    { weight: 11, price: 44 },
    { weight: 1, price: 98 },
    { weight: 6, price: 54 },
    { weight: 7, price: 84 },
    { weight: 13, price: 6 },
    { weight: 0, price: 59 },
    { weight: 16, price: 11 },
    { weight: 15, price: 4 },
    { weight: 10, price: 84 },
    { weight: 16, price: 88 },
    { weight: 8, price: 1 }
    ] 166
    Your result should get the max total price. Tested with: n=166 and items=[{"weight":18,"price":73},{"weight":0,"price":44},{"weight":13,"price":49},{"weight":14,"price":26},{"weight":18,"price":58},{"weight":0,"price":44},{"weight":16,"price":19},{"weight":4,"price":92},{"weight":15,"price":6},{"weight":8,"price":43},{"weight":0,"price":92},{"weight":11,"price":80},{"weight":3,"price":90},{"weight":7,"price":15},{"weight":11,"price":28},{"weight":8,"price":53},{"weight":2,"price":37},{"weight":2,"price":53},{"weight":7,"price":31},{"weight":16,"price":9},{"weight":16,"price":62},{"weight":15,"price":90},{"weight":2,"price":9},{"weight":14,"price":30},{"weight":1,"price":28},{"weight":2,"price":25},{"weight":15,"price":70},{"weight":5,"price":7},{"weight":9,"price":0},{"weight":7,"price":5},{"weight":3,"price":87},{"weight":18,"price":96},{"weight":11,"price":44},{"weight":1,"price":98},{"weight":6,"price":54},{"weight":7,"price":84},{"weight":13,"price":6},{"weight":0,"price":59},{"weight":16,"price":11},{"weight":15,"price":4},{"weight":10,"price":84},{"weight":16,"price":88},{"weight":8,"price":1}]: expected 1626 to equal 1628

  • Custom User Avatar

    weight: 0 because diamonds exist. ( also price: 0 because bricks exist. ) Edge cases are legal and need to be handled correctly.

    Without more specific information ( language, error message, and your code, which might be the problem [ spoilered and marked up please] ), it is not feasible to answer your question about the error. ( Also, please ask one question per post. )

  • Default User Avatar

    i get now! thanks

  • Custom User Avatar

    I cannot make fail your solution. Are you sure there are actually wrong solutions passing? If so, provide a link to them, please.

  • Custom User Avatar

    corrected. Thx

  • Custom User Avatar

    the thief is greedy, not the algorithm. you need to find the optimal solution

  • Default User Avatar

    please review the tests I have the correct answer but it is logging this incorrect error:

    You should not modify the argument items: expected [ { weight: 2, price: 6 }, { weight: 2, price: 3 }, { weight: 6, price: 5 }, { weight: 5, price: 4 }, { weight: 4, price: 6 } ] to deeply equal []

  • Default User Avatar

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

  • Default User Avatar

    done?

  • Default User Avatar

    Thanks Chrono79! Counting the yellow grid makes it clear!

  • Default User Avatar

    Not to solve. That will be counter intuitive, but to explain what it means. e.g explain in a diff way, explain like a child etc.

  • Custom User Avatar

    Why do you wanna use chatgtp for katas ???

  • Custom User Avatar

    It is the perimiter of the land. for every block that is attatched perimiter is +2. When it is the end/start block it is +3.

    [
    [X X X O O X],
    [O X X X O X]
    ]

    The first 6 X's has a perimiter of 12 because 3 top, 3 bottom, 2 left, 2 right, and a displacement of 2 center (because they
    are shifted).

    maybe use a loop, put all X's in a multi dimensional array, use list length to calculate for top, excess or lack of X for center, and len of the overall list to calculate sides. and you would probably have to make sure the X's are connected

  • Default User Avatar

    See the image, you'll see the path to solution.. best of luck

  • Loading more items...