Mixes the elements of multiple lists in a balanced manner based on their proportional lengths.
Project description
Mixes the elements of multiple lists in a balanced manner based on their proportional lengths.
pip install mixbalanced
Tested against Windows 10 / Python 3.10 / Anaconda
This function takes multiple lists as input and returns a new list that contains the elements of the input lists.
The elements are combined in a balanced manner based on their proportional lengths. Longer lists contribute more
elements to the resulting list.
Parameters:
*args: Variable-length argument list, containing multiple lists/tuples.
Returns:
list: A new list containing the elements from the input lists/tuples mixed in a balanced manner.
Example:
from mixbalanced import mix_balanced
l1 = ["Antonio"] * 10
l2 = ["Paulo"] * 5
l3 = ["Anna"] * 15
l4 = ["Maria"] * 3
mix = mix_balanced(l1, l2, l3, l4)
print(mix)
Output: ['Anna', 'Antonio', 'Anna', 'Antonio', 'Paulo', 'Anna', 'Anna', 'Antonio', 'Anna', 'Maria',
'Anna', 'Antonio', 'Paulo', 'Anna', 'Antonio', 'Anna', 'Antonio', 'Paulo', 'Anna', 'Anna',
'Maria', 'Antonio', 'Anna', 'Antonio', 'Paulo', 'Anna', 'Anna', 'Antonio', 'Anna', 'Antonio',
'Paulo', 'Anna', 'Maria']
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
mixbalanced-0.10.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for mixbalanced-0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 814d9f027e5f944910d07c8bf2d24a96632646bd8f317ded67a6d78b6b69ddb5 |
|
MD5 | 98de471719d8f2db433d248ef5b9fb6a |
|
BLAKE2b-256 | 39e68fb3cdece2ff56e9655005720b5bf6935e0bdcc51a273683a130d8c17f3c |