Created
October 25, 2019 15:21
-
-
Save jrwren/40aacb166a63083424d5741a3fe42eb5 to your computer and use it in GitHub Desktop.
permute case
This file contains 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" | |
"strings" | |
) | |
func main() { | |
casePermute("ABCü123") | |
} | |
func casePermute(s string) { | |
n := len(s) | |
max := 1 << n; | |
s = strings.ToLower(s) | |
for i:=0;i<max; i++ { | |
j:=0 | |
comb := strings.Map(func(r rune) rune { | |
if (i>>j) & 1 == 1 { | |
r = []rune(strings.ToUpper(string(r)))[0] | |
} | |
j++ | |
return r | |
}, s) | |
for j:=0 ; j < n; j++ { | |
} | |
fmt.Println(string(comb)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment