diff --git a/day-04/internal/one/solve.go b/day-04/internal/one/solve.go index 773425c..b99f7fb 100644 --- a/day-04/internal/one/solve.go +++ b/day-04/internal/one/solve.go @@ -17,13 +17,13 @@ func Solve(buf []byte) (int, error) { wg := sync.WaitGroup{} sumChan := make(chan bool) - for i := 0; i < len(graph.data); i++ { - for j := 0; j < len(graph.data[i]); j++ { + for y := range graph.data { + for x := range graph.data[y] { wg.Add(1) go func() { defer wg.Done() - current := newPoint(j, i) + current := newPoint(x, y) if graph.valueAt(current) == 'X' { for _, n := range neighbours(current) { sumChan <- checkNeighbours(n, "MAS", graph) diff --git a/day-04/internal/two/solve.go b/day-04/internal/two/solve.go index 2fd1351..548d11c 100644 --- a/day-04/internal/two/solve.go +++ b/day-04/internal/two/solve.go @@ -16,13 +16,13 @@ func Solve(buf []byte) (int, error) { wg := sync.WaitGroup{} sumChan := make(chan bool) - for i := 0; i < len(graph.data); i++ { - for j := 0; j < len(graph.data[i]); j++ { + for y := range graph.data { + for x := range graph.data[y] { wg.Add(1) go func() { defer wg.Done() - current := newPoint(j, i) + current := newPoint(x, y) if graph.valueAt(current) == 'A' { if func() bool { for _, n := range neighbours(current) { diff --git a/day-12/internal/one/solve.go b/day-12/internal/one/solve.go index b03850b..e70d710 100644 --- a/day-12/internal/one/solve.go +++ b/day-12/internal/one/solve.go @@ -15,9 +15,9 @@ func Solve(buf []byte) (int, error) { var totalCost int totalAreaVisited := make(map[point]struct{}) - for i := 0; i < len(graph.data); i++ { - for j := 0; j < len(graph.data[i]); j++ { - start := newPoint(j, i) + for y := range graph.data { + for x := range graph.data[y] { + start := newPoint(x, y) if graph.isOutOfBounds(start) { continue } diff --git a/day-12/internal/two/solve.go b/day-12/internal/two/solve.go index 90e9772..6f05422 100644 --- a/day-12/internal/two/solve.go +++ b/day-12/internal/two/solve.go @@ -15,9 +15,9 @@ func Solve(buf []byte) (int, error) { var totalCost int totalAreaVisited := make(map[point]struct{}) - for i := 0; i < len(graph.data); i++ { - for j := 0; j < len(graph.data[i]); j++ { - start := newPoint(j, i) + for y := range graph.data { + for x := range graph.data[y] { + start := newPoint(x, y) if graph.isOutOfBounds(start) { continue }