knapsack is a package for solving knapsack problem.
- Maximize sum of selected weight.
- Sum of selected size is less than capacity.
- Algorithm: Dynamic Optimization
Usage
import knapsack
size = [21, 11, 15, 9, 34, 25, 41, 52]
weight = [22, 12, 16, 10, 35, 26, 42, 53]
capacity = 100
knapsack.knapsack(size, weight).solve(capacity)
See also https://pypi.org/project/ortoolpy/
Requirements
- Python 3
Setup
$ pip install knapsack
History
- 0.0.1 (2015-6-26): first release
Metadata
Release files for knapsack 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| knapsack-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for knapsack-0.3.1-py3-none-any.whl |
Release files / knapsack-0.3.1-py3-none-any.whl
| Download URL | knapsack-0.3.1-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc12941156a5e79e06373bddc89b3eb61091b0772b24e0d5766abbc88605e469
|
|
BLAKE2b-256 checksum How to use checksums |
d11c43cdefe94c9354e9f9a1f79954adbb3d0fed58abd86027ebdc83f6e18941
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for knapsack 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.