A module for Python in C that solves some dynamic programming problems.
The selected tasks are the following tasks.
1. 0–1 Knapsack problem
In the 0–1 Knapsack problem, we are given a set of items, each with a weight and a value, and we need to determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.
View full on Wiki
2. Rod Cutting Problem
Given a rod of length n
and a list of prices of rods of length i
, where 1 <= i <= n
, find the optimal way to cut the rod into smaller rods to maximize profit.
View full on Wiki
3. Coin Change Problem
Given an unlimited supply of coins of given denominations, find the total number of distinct ways to get the desired change.
View full on Wiki
4. Coin Change-Making Problem
Given an unlimited supply of coins of given denominations, find the minimum number of coins required to get the desired change. That is, you need to find the minimum number of coins to exchange and withdraw this set.
View full on Wiki
5. The Levenshtein Distance Problem
Edit distance is a way of quantifying how different two strings are from one another by counting the minimum number of operations required to transform one string into the other.
View full on Wiki
6. Matrix Chain Multiplication Problem
Matrix chain multiplication is an optimization problem concerning the most efficient way to multiply a given sequence of matrices. The problem is not actually to perform the multiplications, but merely to decide the sequence of the matrix multiplications involved.
View full on Wiki
7. Minimum Cost to Reach Last Cell of Matrix From Its First Cell Problem
Given an M × N
matrix where each cell has a cost associated with it, find the minimum cost to reach the last cell (M-1, N-1)
of the matrix from its first cell (0, 0)
. We can only move one unit right or one unit down from any cell, i.e., from cell (i, j)
, we can move to (i, j+1)
or (i+1, j)
.
View full on Wiki
8. Const Cost to Reach Last Cell of Matrix From Its First Cell Problem
Find the number of paths of a given cost from the upper left to the lower right element of the matrices.
9. Minimum Sum Partition Problem
Given a set of positive integers S
, partition set S
into two subsets, S1
and S2
, such that the difference between the sum of elements in S1
and the sum of elements in S2
is minimized.
View full on Wiki
10. Find All N-digit Binary Strings Without Any Consecutive 1's Problem
Given a positive integer n
, count all n–digit binary strings without any consecutive 1's
.
View full on Wiki
$ ./run
And also you can instant test installed packages
import fdpp
import knapsack
import change_making
Egor Bronnikov | |
Roman Postolnik |
dynamic-programming
provided under the terms of the GPL-3.0 license.
See the LICENSE files for details.
⬆️ Back to top ⬆️