Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
were u being greedy again?
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
weight: 0
because diamonds exist. ( alsoprice: 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. )
i get now! thanks
I cannot make fail your solution. Are you sure there are actually wrong solutions passing? If so, provide a link to them, please.
corrected. Thx
the thief is greedy, not the algorithm. you need to find the optimal solution
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 []
This comment is hidden because it contains spoiler information about the solution
done?
Thanks Chrono79! Counting the yellow grid makes it clear!
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.
Why do you wanna use chatgtp for katas ???
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
See the image, you'll see the path to solution.. best of luck
Loading more items...