Last active
December 25, 2015 09:19
-
-
Save sanikeev/6952900 to your computer and use it in GitHub Desktop.
permutation string golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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