Add day 6 solution.
This commit is contained in:
parent
b8cd01b914
commit
c8cc6d34ae
3 changed files with 84 additions and 18 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue