Select Page
Latest 0.1.8.2 https://github.com/sisoje/RHBCombinatorics MIT ios 8.0, watchos 2.0, osx 10.9, tvos 9.0 Lazar Otasevic

[![CI Status](http://img.shields.io/travis/Lazar Otasevic/RHBCombinatorics.svg?style=flat)](https://travis-ci.org/Lazar Otasevic/RHBCombinatorics)

## Combinations and permutations made easy

Indexed access and iterations are calculated on the fly. There is no caching and no excess memory usage and they work in constant time.

### Iterating trough combinations

Following snippet:

``    RHBCombinations(N: 4, K: 3).enumerated().forEach { print(\$0, \$1) }``

Produces following output:

``````0 [0, 1, 2]
1 [0, 1, 3]
2 [0, 2, 3]
3 [1, 2, 3]``````

### Iterating trough permutations

Following snippet:

``    RHBPermutations(N: 3).enumerated().forEach { print(\$0, \$1) }``

Produces following output:

``````0 [0, 1, 2]
1 [0, 2, 1]
2 [1, 0, 2]
3 [1, 2, 0]
4 [2, 0, 1]
5 [2, 1, 0]``````

### Combinations by index

Following snippet:

``````    let combinatons = RHBCombinations(N: 4, K: 3)
(0..<combinatons.count).forEach {

print(\$0, combinatons[\$0])
}``````

Produces following output:

``````0 [0, 1, 2]
1 [0, 1, 3]
2 [0, 2, 3]
3 [1, 2, 3]``````

## Example application

Example application has a "Powerball" combination generatior, it is generating combinations 5 of 69. Basically it can make your dreams come true 😂

## Installation

RHBCombinatorics is available through CocoaPods. To install

``pod "RHBCombinatorics"``

## Author

Lazar Otasevic, [email protected]

### Latest podspec

```{
"name": "RHBCombinatorics",
"version": "0.1.8.2",
"summary": "Easy iteration trough combinations and permutations.",
"description": "Provide indexed access to combinations and permutations, iterate trough them, indexing...",
"homepage": "https://github.com/sisoje/RHBCombinatorics",
"type": "MIT",
},
"authors": {
"Lazar Otasevic": "[email protected]"
},
"source": {
"git": "https://github.com/sisoje/RHBCombinatorics.git",
"tag": "0.1.8.2"
},
"platforms": {
"ios": "8.0",
"watchos": "2.0",
"osx": "10.9",
"tvos": "9.0"
},
"source_files": "RHBCombinatorics/Classes/**/*",
"pushed_with_swift_version": "3.0"
}```