Add day 6 solution.

This commit is contained in:
Anna Rose Wiggins 2020-12-11 03:32:15 +00:00
parent b8cd01b914
commit c8cc6d34ae
3 changed files with 84 additions and 18 deletions

View file

@ -9,25 +9,9 @@ import (
"strings"
"git.annabunch.es/annabunches/adventofcode/2020/lib/fileutils"
"git.annabunch.es/annabunches/adventofcode/2020/lib/util"
)
func splitPassports(input []string) []string {
converted := []string{}
current := ""
for _, line := range input {
if line == "" {
converted = append(converted, current)
current = ""
continue
}
current += " " + line
}
return converted
}
func countValidPassports(input []string, step string) int {
total := 0
for _, line := range input {
@ -147,7 +131,7 @@ func makeInt(input string) int {
func main() {
step := os.Args[1]
values := fileutils.InputParserStrings(os.Args[2])
values = splitPassports(values)
values = util.SplitOnBlankLine(values)
fmt.Println("Valid Passports:", countValidPassports(values, step))
}