diff --git a/day-5/two.go b/day-5/two.go index 9c5a52b..a4968b1 100644 --- a/day-5/two.go +++ b/day-5/two.go @@ -6,6 +6,7 @@ import ( ) var wg sync.WaitGroup +var mu sync.Mutex const UNLIMITED = -1 @@ -69,7 +70,9 @@ func two(lines []string) int { wg.Add(1) go func(i int) { defer wg.Done() - seedRanges = append(seedRanges, nextTransform(0, []bound{newBound(seeds[i], seeds[i]+seeds[i+1])})...) + mu.Lock() + seedRanges = append(seedRanges, nextTransform(0, []bound{newBound(seeds[i], seeds[i]+seeds[i+1]-1)})...) + mu.Unlock() }(i) }