![]() |
find the sum of a series of values that equal a number - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: find the sum of a series of values that equal a number (/thread-41015.html) |
find the sum of a series of values that equal a number - ancorte - Oct-30-2023 Hello, i'm completely new of Python. I know that there would be a way to determine, form a series of values, which values are corresponding to a certain another value. Example: i have a list of values, 110,230,340,200,500,450 and a another value, for example 840. I want to find for which values, of the first series, theri sum is equal to 840. Is it possibile ? Thanks for the help. RE: find the sum of a series of values that equal a number - Gribouillis - Oct-30-2023 This is a well-known problem in theoretical computer science, the subset sum problem, which is known to be NP-hard, which means that no fast algorithm will solve the problem when the size of the input data is large (eg the length of the list). I have found one package (untested) in the Python Package Index subsetsum but it relies on C++ code. You could perhaps check this package. Apart from this, a search engine finds pure Python implementations such as this one. |