add second answer
This commit is contained in:
parent
7831e58928
commit
777fa8e9d6
|
@ -0,0 +1,36 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
d, _ := ioutil.ReadFile("input")
|
||||||
|
s := string(d)
|
||||||
|
//s := "abc\n\na\nb\nc\n\nab\nac\n\na\na\na\na\n\nb\n"
|
||||||
|
groups := strings.Split(strings.Trim(s,"\n"),"\n\n")
|
||||||
|
total := 0
|
||||||
|
for _, g := range groups {
|
||||||
|
results := make(map[rune]int)
|
||||||
|
lines := strings.Split(g,"\n")
|
||||||
|
for _, l := range lines {
|
||||||
|
for _, c := range l {
|
||||||
|
if _, ok := results[c]; !ok { // if it's not already there
|
||||||
|
results[c] = 1
|
||||||
|
} else {
|
||||||
|
results[c] += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for q, c := range results {
|
||||||
|
if c != len(lines) {
|
||||||
|
delete(results, q)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Println(results)
|
||||||
|
total += len(results)
|
||||||
|
}
|
||||||
|
fmt.Println(total)
|
||||||
|
}
|
Loading…
Reference in New Issue