4 ms·
Always returning the empty list meets your spec.
by lgas 11mo ago
Always returning the empty list meets your spec.
- wongarsu 11mo agoGood point. I suppose we should add "number of input elements equals number of output elements" and "every input element is present in the output". Translated in a straightforward test that still allows my_sort([1,1,2]) to return [1,2,2], but we have to draw the line somewhere
- masklinn 11mo ago> we have to draw the line somewhere Do we? You can pop-count the two lists and checks that those are equal.
- travisjungroth 11mo agoJust use Counter and if the objects aren’t hashable, use the count of IDs. Grab this before calling the function, in case the function is destructive. Check it against the output. Add in checking each item is less than or equal to its successor and you have the fundamental sort properties. You might have more, like stability.