Created
January 27, 2016 02:58
-
-
Save chazcheadle/f7c36fe77f81ce380ce2 to your computer and use it in GitHub Desktop.
Wheel / Side combinations
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" | |
| import "encoding/json" | |
| var alphabetsJSON = []byte(`[{"Name":"I","Side":{"a":"XGBRCJSQIEFTVHYAPOWZNULKMD","b":"REHKVMQTFSJNXBWZGDOALCUPIY"}},{"Name":"II","Side":{"a":"SUBWDVRFMKHPOLZCGXINQAJEYT","b":"YOBEZALKIHRCUFVQWTSMPXGNJD"}}, | |
| {"Name":"III","Side":{"a":"VIWNXUPTCRHJMBZYAKDOLQSEGF","b":"DUSYOCQGZALBKFWHJIVEMPXRNT"}},{"Name":"IV","Side":{"a":"DASQOPELGKUVBTWYRCINHMXJFZ","b":"ZFTIKGOPJLYUDHNMAWVSRECXBQ"}},{"Name":"V","Side":{"a":"OSADNJLUXCRQZTHEVBGFYIPKWM","b":"REHKVMQTFSJNXBWZGDOALCUPIY"}},{"Name":"VI","Side":{"a":"djrifhdhdhdbej","b":"igfjdhfjdj"}}]`) | |
| func main () { | |
| type Alphabet struct { | |
| Name string | |
| Side map[string]string | |
| } | |
| var alphabets []Alphabet | |
| err := json.Unmarshal(alphabetsJSON, &alphabets) | |
| if err != nil { | |
| fmt.Println("error:",err) | |
| } | |
| i := 0 | |
| var comb = map[int]string{} | |
| for w1 := range alphabets { | |
| w1n := alphabets[w1].Name | |
| for s1 := range alphabets[w1].Side { | |
| fmt.Println(w1n+s1) | |
| comb[0] = w1n+s1 | |
| for w2 := range alphabets { | |
| w2n := alphabets[w2].Name | |
| if w2n != w1n { | |
| for s2 := range alphabets[w2].Side { | |
| comb[1] = w2n+s2 | |
| for w3 := range alphabets { | |
| w3n := alphabets[w3].Name | |
| if w3n != w2n && w3n != w1n { | |
| for s3 := range alphabets[w3].Side { | |
| comb[2] = w3n+s3 | |
| fmt.Println(comb) | |
| i++ | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| fmt.Println("Total permutations:",i) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment