Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reity/summations-py
Library to enumerate all natural number lists with a target sum.
https://github.com/reity/summations-py
combinations enumeration exhaustive-search mathematics python-library
Last synced: 29 days ago
JSON representation
Library to enumerate all natural number lists with a target sum.
- Host: GitHub
- URL: https://github.com/reity/summations-py
- Owner: reity
- License: mit
- Created: 2019-12-05T05:44:41.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T06:36:25.000Z (about 5 years ago)
- Last Synced: 2024-11-01T11:19:05.638Z (about 2 months ago)
- Topics: combinations, enumeration, exhaustive-search, mathematics, python-library
- Language: Python
- Homepage: https://pypi.org/project/summations
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
==========
summations
==========
Library to enumerate all natural number lists with a target sum... image:: https://badge.fury.io/py/summations.svg
:target: https://badge.fury.io/py/summations
:alt: PyPI version and link.Purpose
-------
This library allows programmers to create a generator for all the lists of natural numbers that add up to a target sum.Package Installation and Usage
------------------------------
The package is available on PyPI::python -m pip install summations
The library can be imported in the usual way::
import summations
from summations import summationsTesting
-------The library comes with a number of tests::
nosetests
Examples
--------
An example of usage is provided below::>>> from summations import summations
>>> sorted(list(sum_len(5, 3)))
[(0, 0, 5), (0, 1, 4), (0, 2, 3), (0, 3, 2), (0, 4, 1), (0, 5, 0),
(1, 0, 4), (1, 1, 3), (1, 2, 2), (1, 3, 1), (1, 4, 0), (2, 0, 3),
(2, 1, 2), (2, 2, 1), (2, 3, 0), (3, 0, 2), (3, 1, 1), (3, 2, 0),
(4, 0, 1), (4, 1, 0), (5, 0, 0)]