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
- Host: GitHub
- URL: https://github.com/tsmith023/go-permutate
- Owner: tsmith023
- License: mit
- Created: 2022-11-10T20:46:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-11T11:29:04.000Z (about 3 years ago)
- Last Synced: 2025-02-07T06:31:28.217Z (about 1 year ago)
- Topics: generics-in-golang, goroutines, permutation-algorithms
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.