linear-partitioning

0.3.2 • Public • Published

linear partitioning

Input: given an array of S non-negative numbers and an integer k (the number of partitions we want)

Output: Partition S into k ranges, so as to minimize the maximum sum over all the ranges.

var partition = require('linear-partitioning');
 
partition([1,2,3,4,5,6,7,8,9], 3);
// returns  [[1,2,3,4,5], [6,7], [8,9]]

See http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM

development

Run tests with npm run test or tape test | faucet

Run benchmarks with node benchmarks

benchmarks

This library was a re-implementation of a horrendous coffeescript function that people used to use. Here are benchmark results when compared to that older implementation:

Winner: ours
Compared with next highest (coffeescript), it's:
91.73% faster
12.09 times as fast
1.08 order(s) of magnitude faster
A LOT FASTER

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.2
    330
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.2
    330
  • 0.3.1
    1
  • 0.3.0
    1
  • 0.2.0
    1
  • 0.0.1
    1

Package Sidebar

Install

npm i linear-partitioning

Weekly Downloads

273

Version

0.3.2

License

MIT

Last publish

Collaborators

  • jayrbolton
  • the_swerve