Library to enumerate all natural number lists with a target sum.
Project description
Library to enumerate all natural number lists with a target sum.
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 summations
Testing
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)]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
summations-0.0.9.0.tar.gz
(2.1 kB
view hashes)
Built Distribution
Close
Hashes for summations-0.0.9.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 700626504e7f6fffb8d921b27c142dc8df6aa32cb3c76d54eeb588fa13b432f4 |
|
MD5 | 2a735958c8c44ce57ff72e8453a21f4b |
|
BLAKE2b-256 | 6e5b2d7046502e5aed63840599e9b6414e8a9b455907f1a91fc648313ccb21a0 |