diff --git a/internal/2020/DayFour/code.go b/internal/2020/DayFour/code.go index bb7d5a0..c18bf00 100644 --- a/internal/2020/DayFour/code.go +++ b/internal/2020/DayFour/code.go @@ -37,8 +37,8 @@ func PartOne(data []string) int { fields := strings.Fields(passport) present := make(map[string]bool) for _, field := range fields { - if idx := strings.Index(field, ":"); idx != -1 { - present[field[:idx]] = true + if before, _, ok := strings.Cut(field, ":"); ok { + present[before] = true } } missing := false