https://github.com/technically-php/linear-partitioning
A simple library to solve linear partitioning problem [O(n²)]
https://github.com/technically-php/linear-partitioning
dynamic-programming linear-parition php php7
Last synced: 9 months ago
JSON representation
A simple library to solve linear partitioning problem [O(n²)]
- Host: GitHub
- URL: https://github.com/technically-php/linear-partitioning
- Owner: technically-php
- Created: 2017-02-20T18:18:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-11-28T11:20:50.000Z (about 3 years ago)
- Last Synced: 2025-03-10T10:44:47.078Z (10 months ago)
- Topics: dynamic-programming, linear-parition, php, php7
- Language: PHP
- Size: 14.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# PHP solution to Linear Partition Problem
Based on a description from [The Algorithm Design Manual](http://www.algorist.com/) book by *Steven S. Skiena*.
* Leverages the Dynamic Programming principle
* *O(n²)* complexity
* Fully annotated code
* Test suite
* Semver
## Installation
```bash
composer require technically-php/linear-partitioning:^1.0
```
## Usage
```php
use \TechnicallyPhp\LinearPartitioning\LinearPartitioning;
$items = [100, 200, 300, 400, 500, 600, 700, 800, 900];
$ranges = LinearPartitioning::partition($items, 3);
var_dump($ranges);
// [ [100, 200, 300, 400, 500], [600, 700], [800, 900] ]
```
## Credits
* Implemented by [Ivan Voskoboinyk](https://github.com/e1himself)