From 00815609cb37ea1b074b9b924401827189fdd91a Mon Sep 17 00:00:00 2001 From: Davide Oddone Date: Sat, 2 Dec 2023 16:34:29 +0000 Subject: [PATCH] Small refactor of code --- day02/lottacubes.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/day02/lottacubes.go b/day02/lottacubes.go index e6cbecc..ccbd344 100644 --- a/day02/lottacubes.go +++ b/day02/lottacubes.go @@ -81,12 +81,11 @@ func findMinimumSet(mySet map[string]int, m *minimumSet) { } func PossibleGamesSum(s string, gn int, gt *int) { - var isPossible possibleGame // Initialize everything to true. If everything was set to false, // we would have to check in both directions for every pass - isPossible.redIsPossible = true - isPossible.greenIsPossible = true - isPossible.blueIsPossible = true + isPossible := possibleGame{redIsPossible: true, + greenIsPossible: true, + blueIsPossible: true} // We will pass a pointer so we can go one map at a time and // still maintain the results var isPossiblePoint *possibleGame @@ -129,8 +128,8 @@ func PowerSetsSum(s string, pt *int) { for i := 0; i < numSets; i++ { // We create a map mySet = newGameSet(sets[i]) - // We check if the game is possible - findMinimumSet(mySet, minSetPoint) + // We find the minimum set + findMinimumSet(mySet, minSetPoint) } *pt += (minSet.red * minSet.green * minSet.blue) }