|
|
@@ -0,0 +1,101 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import "bufio"
|
|
|
+import "fmt"
|
|
|
+import "os"
|
|
|
+
|
|
|
+type RuneList struct {
|
|
|
+ runes map[rune]int
|
|
|
+}
|
|
|
+
|
|
|
+type Code struct {
|
|
|
+ runes [8]RuneList
|
|
|
+}
|
|
|
+
|
|
|
+func (this *RuneList) AppendRune(in rune) {
|
|
|
+ this.runes[in]++
|
|
|
+}
|
|
|
+
|
|
|
+func (this RuneList) GetBest() rune {
|
|
|
+ var bestRune rune
|
|
|
+ bestInt := 0
|
|
|
+
|
|
|
+ for i, j := range(this.runes) {
|
|
|
+ if j > bestInt {
|
|
|
+ bestInt = j
|
|
|
+ bestRune = i
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bestRune
|
|
|
+}
|
|
|
+
|
|
|
+func (this RuneList) GetWorst() rune {
|
|
|
+ var bestRune rune
|
|
|
+ bestInt := len(this.runes)
|
|
|
+
|
|
|
+ for i, j := range(this.runes) {
|
|
|
+ if j < bestInt {
|
|
|
+ bestInt = j
|
|
|
+ bestRune = i
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bestRune
|
|
|
+}
|
|
|
+
|
|
|
+func NewRuneList() RuneList {
|
|
|
+ var r RuneList
|
|
|
+ r.runes = make(map[rune]int)
|
|
|
+ return r
|
|
|
+}
|
|
|
+
|
|
|
+func (this *Code) Append(in string) {
|
|
|
+ for i := 0; i < 8; i++ {
|
|
|
+ this.runes[i].AppendRune(rune(in[i]))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (this Code) GetBest() string {
|
|
|
+ var result string
|
|
|
+
|
|
|
+ for i := 0; i < 8 ; i++ {
|
|
|
+ result += string(this.runes[i].GetBest())
|
|
|
+ }
|
|
|
+ return result
|
|
|
+}
|
|
|
+
|
|
|
+func (this Code) GetWorst() string {
|
|
|
+ var result string
|
|
|
+
|
|
|
+ for i := 0; i < 8 ; i++ {
|
|
|
+ result += string(this.runes[i].GetWorst())
|
|
|
+ }
|
|
|
+ return result
|
|
|
+}
|
|
|
+
|
|
|
+func NewCode() Code {
|
|
|
+ var this Code
|
|
|
+ for i :=0; i < 8; i++ {
|
|
|
+ this.runes[i] = NewRuneList()
|
|
|
+ }
|
|
|
+ return this
|
|
|
+}
|
|
|
+
|
|
|
+func main() {
|
|
|
+ reader := bufio.NewReader(os.Stdin)
|
|
|
+ codeList := NewCode()
|
|
|
+
|
|
|
+ for true {
|
|
|
+ line, err := reader.ReadString('\n')
|
|
|
+ if len(line) == 9 {
|
|
|
+ line = line[0:len(line) -1]
|
|
|
+ codeList.Append(line)
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result := codeList.GetWorst()
|
|
|
+ fmt.Println(result)
|
|
|
+}
|
|
|
+
|