Skip to content

Instantly share code, notes, and snippets.

@jrwren
Created October 25, 2019 15:21
Show Gist options
  • Save jrwren/40aacb166a63083424d5741a3fe42eb5 to your computer and use it in GitHub Desktop.
Save jrwren/40aacb166a63083424d5741a3fe42eb5 to your computer and use it in GitHub Desktop.
permute case
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