number-partitioner

0.1.1 • Public • Published

Gernerates partitions for positive interger

See Wikipedia for more info.

e.g. partitions of 8 are:

[
    [8],
    [7, 1],
    [6, 2],
    [6, 1, 1],
    [5, 3],
    [5, 2, 1],
    [5, 1, 1, 1],
    [4, 4],
    [4, 3, 1],
    [4, 2, 2],
    [4, 2, 1, 1],
    [4, 1, 1, 1, 1],
    [3, 3, 2],
    [3, 3, 1, 1],
    [3, 2, 2, 1],
    [3, 2, 1, 1, 1],
    [3, 1, 1, 1, 1, 1],
    [2, 2, 2, 2],
    [2, 2, 2, 1, 1],
    [2, 2, 1, 1, 1, 1],
    [2, 1, 1, 1, 1, 1, 1],
    [1, 1, 1, 1, 1, 1, 1, 1]
]

Currently able to generate partions for 1..65 (after that it usually fails with out of memory exception).Number of partitions grows exponentially, it takes a lot of memory. Uses caching and can be optimized further to reduce memory footprint by several times.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    4
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    4
  • 0.1.0
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i number-partitioner

Weekly Downloads

4

Version

0.1.1

License

ISC

Last publish

Collaborators

  • restuta