Skip to main content

A python implementation of the Knapsack problem using dynamic programming.

Project description

Knapsack Algorithm

knapsack_algorithm is a Python package that provides a simple and efficient solution for the 0/1 knapsack problem.

Features

  • Dynamic Programming Solution: Utilizes dynamic programming to solve the 0/1 knapsack problem efficiently.
  • Error Handling: Provides comprehensive error handling for input validation.
  • Easy to Use: Offers a user-friendly interface for solving knapsack problems with given values, weights, and capacity.

Installation:

You can install KnapsackAlgorithm using pip:

pip install knapsack_algorithm

Usage:

Here's an example of how you can use knapsack_algorithm:

from knapsack_algorithm import knapsack

Documentation

For detailed documentation and additional options, refer to the official documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

If you would like to contribute or report issues, please check our contribution guidelines.

Example usage:

values = [60, 100, 120]  # The values of the items

weights = [10, 20, 30]  # The weights of the items

capacity = 50  # The maximum capacity

result = knapsack(values, weights, capacity)

if result is not None:

      print("Maximum value in the knapsack:", result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knapsack_algorithm-1.0.0.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distribution

knapsack_algorithm-1.0.0-py3-none-any.whl (1.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page