1.0.2 • Published 7 years ago

knapsack-js v1.0.2

Weekly downloads
15
License
MIT
Repository
github
Last release
7 years ago

Knapsack

NPM Build Status

Knapsack is a module for resource allocation solving. See wiki page for more details.

Installation

npm install knapsack-js

Usage

var knapsack = require('knapsack-js');

var items = [
      {"pear": 1},
      {"apple": 7},
      {"grape": 0},
      {"banana": 2},
      {"orange": "NA"},
      {"strawberry": 4},
      {"mandarin": null},
      {"durian": 1},
      {"peach": undefined},
      {}
    ];

knapsack.resolve(5, items);
// [ { strawberry: 4 }, { pear: 1 } ]

knapsack.resolve(1, items);
// [ { pear: 1 } ]

knapsack.resolve(7, items);
// [ { apple: 7 } ]

knapsack.resolve(15, items);
/*
[ { apple: 7 },
  { strawberry: 4 },
  { banana: 2 },
  { pear: 1 },
  { durian: 1 } ]
*/

License

Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.

1.0.2

7 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago