adventofcode/day6/main.go

28 lines
475 B
Go

package main
import (
"fmt"
"io/ioutil"
"strings"
)
func main() {
d, _ := ioutil.ReadFile("input")
s := string(d)
groups := strings.Split(s, "\n\n")
total := 0
for _, g := range groups {
results := make(map[rune]bool)
lines := strings.Split(g, "\n")
for _, l := range lines {
for _, c := range l {
if _, ok := results[c]; !ok { // if it's not already accounted for
results[c] = true
}
}
}
total += len(results)
}
fmt.Println(total)
}