ldm-partition
Version:
Largest differencing method
23 lines (15 loc) • 454 B
Markdown
Implementation based on algorithm invented by
[](https://en.wikipedia.org/wiki/Largest_differencing_method).
```sh
npm install ldm-partition
```
```js
import partition from 'ldm-partition';
partition([8, 7, 6, 5, 4], 2);
//=> [[4, 7, 5], [8, 6]]
partition([{ x: 2 }, { x: 4 }], 2, (d) => d.x));
//=> [[{ x: 4 }], [{ x: 2 }]]
```