Skip to content

Instantly share code, notes, and snippets.

@sanikeev
Last active December 25, 2015 09:19
Show Gist options
  • Save sanikeev/6952900 to your computer and use it in GitHub Desktop.
Save sanikeev/6952900 to your computer and use it in GitHub Desktop.
permutation string golang
package main
import "fmt"
var arr []string
func main(){
// array
arr = make([]string,0)
force("asd", 3, "", func(thisString string){
/// array += thisString
arr = append(arr, thisString)
//fmt.Println(thisString);
})
fmt.Println(arr)
}
func force(str string, n int, thisString string,
callback func(thisString string)) {
if n == 0 {
callback(thisString);
return;
}
for _, v := range(str) {
force(str, n-1, thisString + string(v), callback)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment