Latest 0.1.8.2
Homepage https://github.com/sisoje/RHBCombinatorics
License MIT
Platforms ios 8.0, watchos 2.0, osx 10.9, tvos 9.0
Authors

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

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
it, simply add the following line to your Podfile:

pod "RHBCombinatorics"

Author

Lazar Otasevic, [email protected]

License

RHBCombinatorics is available under the MIT license. See the LICENSE file for more info.

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",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "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"
}

Pin It on Pinterest

Share This