Ad
  • Default User Avatar

    Very nice kata! Thanks!

  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Custom User Avatar

    Thanks for bringing that up; Will have to get that fixed up!

  • Custom User Avatar

    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.

  • Custom User Avatar

    I've aded a fourth test which should satisfy the random factor, and also will more than likely have more than 10 items output

  • Custom User Avatar

    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?

  • Default User Avatar

    Does not have random tests, nor tests for shipping more than 10 items, which should then be spliot in packages.