From 137cfd379b3173bbe0a98f03fddf05cfc3c3353c Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sun, 12 Dec 2021 13:07:36 -0500 Subject: [PATCH] don't need the top-level waitgroup --- 12/main.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/12/main.go b/12/main.go index 0d11243..702711b 100644 --- a/12/main.go +++ b/12/main.go @@ -108,13 +108,7 @@ func partOne() { rooms[p[1]] = b } successes := make(chan bool, 10000) - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - descend(rooms, "start", []string{}, successes, false) - }() - wg.Wait() + descend(rooms, "start", []string{}, successes, false) fmt.Printf("%+v\n", len(successes)) } func partTwo() { @@ -140,12 +134,6 @@ func partTwo() { rooms[p[1]] = b } successes := make(chan bool, 200000) - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - descend(rooms, "start", []string{}, successes, true) - }() - wg.Wait() + descend(rooms, "start", []string{}, successes, true) fmt.Printf("%+v\n", len(successes)) }