An open API service indexing awesome lists of open source software.

https://github.com/tsmith023/go-permutate

A repository containing methods to compute and generate generic permutations using Go
https://github.com/tsmith023/go-permutate

generics-in-golang goroutines permutation-algorithms

Last synced: about 1 year ago
JSON representation

A repository containing methods to compute and generate generic permutations using Go

Awesome Lists containing this project

README

          

# go-permutate

This repository hosts the beginnings of a Go package for computing the [permutations](https://en.wikipedia.org/wiki/Permutation) of generic slices as generator functions leveraging goroutines under-the-hood.

So far implemented are [Heap's Algorithm](https://en.wikipedia.org/wiki/Heap's_algorithm), in both flat and recursive forms, for finding all possible permutations and [Fisher-Yates-Shuffling](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle) & [Reservoir Sampling](https://en.wikipedia.org/wiki/Reservoir_sampling) for finding permutations randomly until a predefined number have been obtained.

The benefit of the latter type of generation over the former is if the permutated slice has a length greater than eleven such that finding all its possible permutations is unfeasible, since Heap's Algorithm has order ${\cal O}(n!)$ so that finding (>12)! permutations takes many minutes, if not hours. The latter technique can find a representative sample of the underlying permutations of a slice when the length of the slice is much greater than 12.