{"id":16138980,"url":"https://github.com/slxiao/partition","last_synced_at":"2025-03-18T16:31:05.343Z","repository":{"id":56008221,"uuid":"223327839","full_name":"slxiao/partition","owner":"slxiao","description":":beginner: Python number partition algorithm library ","archived":false,"fork":false,"pushed_at":"2020-12-01T15:36:07.000Z","size":68,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T10:52:37.280Z","etag":null,"topics":["algorithms","number-partitioning","parallel-testing","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slxiao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-22T05:09:20.000Z","updated_at":"2023-03-23T19:18:07.000Z","dependencies_parsed_at":"2022-08-15T11:20:18.556Z","dependency_job_id":null,"html_url":"https://github.com/slxiao/partition","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slxiao%2Fpartition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slxiao%2Fpartition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slxiao%2Fpartition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slxiao%2Fpartition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slxiao","download_url":"https://codeload.github.com/slxiao/partition/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940108,"owners_count":20372045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","number-partitioning","parallel-testing","python"],"created_at":"2024-10-09T23:46:43.029Z","updated_at":"2025-03-18T16:31:05.338Z","avatar_url":"https://github.com/slxiao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg alt=\"madge\" src=\"https://github.com/slxiao/partition/blob/master/logo.png\" width=\"200\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg alt=\"Last version\" src=\"https://img.shields.io/github/tag/slxiao/partition.svg?style=flat-square\" /\u003e\n\t\u003ca href=\"https://travis-ci.org/slxiao/partition\"\u003e\n\t\t\u003cimg alt=\"Build Status\" src=\"http://img.shields.io/travis/slxiao/partition/master.svg?style=flat-square\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://pypi.org/project/partition/\"\u003e\n\t\t\u003cimg alt=\"Python Version\" src=\"https://img.shields.io/pypi/pyversions/partition.svg\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://coveralls.io/github/slxiao/partition?branch=master\"\u003e\n\t\t\u003cimg alt=\"Coverage\" src=\"https://coveralls.io/repos/github/slxiao/partition/badge.svg?branch=master\" /\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://pepy.tech/project/partition\"\u003e\n\t\t\u003cimg alt=\"Downloads\" src=\"https://pepy.tech/badge/partition\" /\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n# partition\n`partiton` is a Python algorithm library which provides efficient algorithms for the [number partition problem](https://en.wikipedia.org/wiki/Partition_problem). You can also use it from shell command. These algorithms have many applications. One typical one is for [parallel software testing](https://mp.weixin.qq.com/s/oq3-mJ7cA6f_lK0SviMVyw). Currently, the following three algorithms are supported:\n- greedy algorithm, which is a benchmark algorithm with simple login\n- differencing algorithm, a.k.a. Karmarkar–Karp(KK) algorithm\n- dynamic programming(DP) algorithm, which is optimal for scenarios where the size of integers is not too large\n\n# Install\nUse pip:\n```shell\npip install partition\n```\nFrom source code:\n```shell\npython setup.py develop\n```\n# How to use\n## command line usage\nGet help:\n```shell\npartition -h\n```\nQuery version:\n```shell\npartition --version\n```\nAvailable options:\n```shell\nusage: partition [-h] [--numbers NUMBERS] [--grouplen GROUPLEN]\n                 [--algorithm {greedy,kk,dp}] [--version]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --numbers NUMBERS     integer numbers to be partitioned, seperated by comma\n  --grouplen GROUPLEN   length of groups to hold the partitioned integer\n                        numbers, default is 2\n  --algorithm {greedy,kk,dp}\n                        select partition algorithms, available options are\n                        greedy, kk and dp\n  --version             print version\n```\nFor example:\n```shell\nroot@foo:~# partition --numbers 1,2,3,4,5 --grouplen 2 --algorithm greedy\nPartition 1,2,3,4,5 into 2 groups, using algorithm: greedy\nGroup: 0, numbers: [5, 2, 1]\nGroup: 1, numbers: [4, 3]\nMin group sum: 7, Max group sum: 8, difference: 1\nGroup(s) with min sum: [4, 3]\nGroup(s) with max sum: [5, 2, 1]\n([[5, 2, 1], [4, 3]], 1)\n```\n\n## python library usage\n```python\nIn [1]: import partition\n\nIn [2]: partition.partition.__version__\nOut[2]: '0.1.0'\n\nIn [3]: partition.greedy.greedy([1,2,3,4,5], 2)\nOut[3]: [[5, 2, 1], [4, 3]]\n\nIn [4]: partition.kk.kk([1,2,3,4,5], 2)\nOut[5]: [[5, 3], [1, 2, 4]]\n```\n\n# Lisense\nMIT\n# Maintenance\nThis tool is developed by [slxiao](https://github.com/slxiao). You are welcome to raise any [issues](https://github.com/slxiao/partition/issues) about the tool.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslxiao%2Fpartition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslxiao%2Fpartition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslxiao%2Fpartition/lists"}