refactor: use Cut() instead of Index()
This commit is contained in:
@@ -37,8 +37,8 @@ func PartOne(data []string) int {
|
|||||||
fields := strings.Fields(passport)
|
fields := strings.Fields(passport)
|
||||||
present := make(map[string]bool)
|
present := make(map[string]bool)
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
if idx := strings.Index(field, ":"); idx != -1 {
|
if before, _, ok := strings.Cut(field, ":"); ok {
|
||||||
present[field[:idx]] = true
|
present[before] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
missing := false
|
missing := false
|
||||||
|
|||||||
Reference in New Issue
Block a user