diff --git a/12/main.go b/12/main.go index 702711b..be73e21 100644 --- a/12/main.go +++ b/12/main.go @@ -63,10 +63,10 @@ func doubleSmallAlready(visitedRooms []string) bool { return false } -func descend(rooms map[string]room, currentRoom string, path []string, success chan bool, canVisitSmallRoomTwice bool) { +func descend(rooms map[string]room, currentRoom string, path []string, success chan struct{}, canVisitSmallRoomTwice bool) { var wg sync.WaitGroup if currentRoom == "end" { - success <- true + success <- struct{}{} return } for _, link := range rooms[currentRoom].links { @@ -107,10 +107,11 @@ func partOne() { rooms[p[0]] = a rooms[p[1]] = b } - successes := make(chan bool, 10000) + successes := make(chan struct{}, 10000) descend(rooms, "start", []string{}, successes, false) fmt.Printf("%+v\n", len(successes)) } + func partTwo() { scanner := makeScanner(false) @@ -133,7 +134,7 @@ func partTwo() { rooms[p[0]] = a rooms[p[1]] = b } - successes := make(chan bool, 200000) + successes := make(chan struct{}, 200000) descend(rooms, "start", []string{}, successes, true) fmt.Printf("%+v\n", len(successes)) }