Socket
Socket
Sign inDemoInstall

linear-partitioning

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    linear-partitioning

Given an array of numbers, partition them into a number of buckets, preserving order, where the ranges of each bucket are as close as possible.


Version published
Weekly downloads
215
increased by7.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 22 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc