From 9ba5ad695e71217c33422124759fd83bc6af06d9 Mon Sep 17 00:00:00 2001 From: onyx Date: Tue, 2 Jan 2024 06:58:03 +0000 Subject: [PATCH] add mutex lock --- day-5/two.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/day-5/two.go b/day-5/two.go index 1fc2ed6..aae550e 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 @@ -68,7 +69,9 @@ func two(lines []string) int { wg.Add(1) go func(i int) { defer wg.Done() + mu.Lock() seedRanges = append(seedRanges, nextTransform(0, []bound{newBound(seeds[i], seeds[i]+seeds[i+1]-1)})...) + mu.Unlock() }(i) }