36 lines
659 B
Go
36 lines
659 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
"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)
|
|
}
|
|
}
|
|
total += len(results)
|
|
}
|
|
fmt.Println(total)
|
|
}
|