mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 22:30:47 +00:00
use x := range and y := range, easier to read.
This commit is contained in:
parent
75d10fffd0
commit
5d6d8fdf79
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user