refactor: use Cut() instead of Index()

This commit is contained in:
2026-03-16 15:35:06 +01:00
parent 0324193a95
commit 3bbe8d9f7d

View File

@@ -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