solve day 6 part 1

This commit is contained in:
Nico 2020-12-06 12:56:33 +00:00
parent 2083f92e40
commit 7831e58928
2 changed files with 2106 additions and 0 deletions

2079
day6/input Normal file

File diff suppressed because it is too large Load Diff

27
day6/main.go Normal file
View File

@ -0,0 +1,27 @@
package main
import (
"io/ioutil"
"fmt"
"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)
}