Generate the power set of a collection
Project description
Python Power set generator
Installation
pip install powerset-generator
Example
import powerset_generator
for e in powerset_generator.subsets(["one", "two", "three", "three"]):
print(e)
produces
set()
{'one'}
{'three'}
{'two'}
{'one', 'three'}
{'one', 'two'}
{'three', 'two'}
{'one', 'three', 'two'}
Note that the empty set, set() is included in the output
and that the function treats the duplicated input element "three" as if it appeared only once.
This is correct behavior the mathematical notion of power set.
See the more complete (perhaps excessively so) documentation for more details.
Credit
The code for the subsets() function is derived heavily from
Allen Downey's
Stack Overflow answer.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file powerset_generator-0.1.3.tar.gz.
File metadata
- Download URL: powerset_generator-0.1.3.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60230a2218ecf8c25d59c0581ab8c17df7694f960f2949bd1c8a9854f0c13607
|
|
| MD5 |
88db3a988b459e226953cd89411aa35e
|
|
| BLAKE2b-256 |
72c1f491bb2888ecac1846efb2e5f6d3fd7716d9db13e2721a9292353f229b57
|
File details
Details for the file powerset_generator-0.1.3-py3-none-any.whl.
File metadata
- Download URL: powerset_generator-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
737b37b941c64463ed216a0f640bd111866b3b85bbbe2caa37bdc14113e8ff51
|
|
| MD5 |
2b9317a02a794b9339cd90e5e26f3bc0
|
|
| BLAKE2b-256 |
5b787351aec2c11c9479fc7026cb7bb033ec32f14a170785079a8b264da3af97
|