Documentation
¶
Overview ¶
Library that provides to drawn combinations.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Every ¶
A range iterator over every possible combinations (of length from 1 to the length of the specified slice) of slice elements without repeating elements within a single combination.
The returned slice of combination is valid only for current iteration of the loop.
Example ¶
package main
import (
"fmt"
"github.com/akramarenkov/combin"
)
func main() {
for combination := range combin.Every([]int{4, 3, 2, 1}) {
fmt.Println(combination)
}
}
Output: [4] [4 3] [4 3 2] [4 3 2 1] [4 3 1] [4 2] [4 2 1] [4 1] [3] [3 2] [3 2 1] [3 1] [2] [2 1] [1]
func EveryQuantity ¶
Returns the quantity of combinations that can be obtained from the Every function.
If the number of combinations for n elements is m, then for n+1 elements the number of combinations is m + m + 1. It is easy to see that such an increment corresponds to the function 2^n - 1.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.