Implement the perm() function that accepts a slice or string and prints all possible combinations of characters.
Solution
Package main
import "fmt"
// Perm calls f with each permutation of a.
func Perm(a []rune, f func([]rune)) {
perm(a, f, 0)
}
// Permute the values at index i to len(a)-1.
Run
We use rune types to handle both slices and strings. Runes are Unicode code points and can therefore parse strings and slices equally.