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.
Very nice kata! Thanks!
So it seems that the problem is in handling equal-priority.
As we can see from the line
if (... element.priority <= max) {
pay attention that it's<=
, not<
if there are items with equal priority, @ben-hig's solution always takes the rightmost one.
Since order for items with same priorities are not specified in kata description, technically @ben-nig is right.
@jfrei, it seems that you're expecting FIFO, but does not explicitly require that in solution.
Moreover, language specification does not guarantee that built-in sort is stable: es5.1, es6.0
Hey ben-hig: So, I went through the test cases for the solution, but it is using a very simple sort function:
items.sort(function(a,b) {return a.priority - b.priority;});
Without trying to 'point a finger' at your code, I think there is some inconsistency with how you are dealing with sorting the items. I tried to get your solution to work by modifiying the test case sort, but that doesn't help at all. I think you may need to modify your solution to handle the sorting properly.Thanks for bringing that up; Will have to get that fixed up!
My solution doesn't pass sometimes on the last randomized test case, and it seems to be due to inconsistency with how the case of two items having the same priority is handled. It seems to be a toss-up for which one is shipped first.
I've aded a fourth test which should satisfy the random factor, and also will more than likely have more than 10 items output
Are we talking about example test cases or the actual test cases? If the actual test cases, the third test case has a random number of items, from 4 - 32 which would fit the multiple shipment criteria. In any case, I could always rework that last test case, or add one more that randomizes the number of assembly lines and items? Would that help?
Does not have random tests, nor tests for shipping more than 10 items, which should then be spliot in packages.