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{}
|
wg := sync.WaitGroup{}
|
||||||
sumChan := make(chan bool)
|
sumChan := make(chan bool)
|
||||||
|
|
||||||
for i := 0; i < len(graph.data); i++ {
|
for y := range graph.data {
|
||||||
for j := 0; j < len(graph.data[i]); j++ {
|
for x := range graph.data[y] {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
current := newPoint(j, i)
|
current := newPoint(x, y)
|
||||||
if graph.valueAt(current) == 'X' {
|
if graph.valueAt(current) == 'X' {
|
||||||
for _, n := range neighbours(current) {
|
for _, n := range neighbours(current) {
|
||||||
sumChan <- checkNeighbours(n, "MAS", graph)
|
sumChan <- checkNeighbours(n, "MAS", graph)
|
||||||
|
@ -16,13 +16,13 @@ func Solve(buf []byte) (int, error) {
|
|||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
sumChan := make(chan bool)
|
sumChan := make(chan bool)
|
||||||
|
|
||||||
for i := 0; i < len(graph.data); i++ {
|
for y := range graph.data {
|
||||||
for j := 0; j < len(graph.data[i]); j++ {
|
for x := range graph.data[y] {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
current := newPoint(j, i)
|
current := newPoint(x, y)
|
||||||
if graph.valueAt(current) == 'A' {
|
if graph.valueAt(current) == 'A' {
|
||||||
if func() bool {
|
if func() bool {
|
||||||
for _, n := range neighbours(current) {
|
for _, n := range neighbours(current) {
|
||||||
|
@ -15,9 +15,9 @@ func Solve(buf []byte) (int, error) {
|
|||||||
|
|
||||||
var totalCost int
|
var totalCost int
|
||||||
totalAreaVisited := make(map[point]struct{})
|
totalAreaVisited := make(map[point]struct{})
|
||||||
for i := 0; i < len(graph.data); i++ {
|
for y := range graph.data {
|
||||||
for j := 0; j < len(graph.data[i]); j++ {
|
for x := range graph.data[y] {
|
||||||
start := newPoint(j, i)
|
start := newPoint(x, y)
|
||||||
if graph.isOutOfBounds(start) {
|
if graph.isOutOfBounds(start) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ func Solve(buf []byte) (int, error) {
|
|||||||
|
|
||||||
var totalCost int
|
var totalCost int
|
||||||
totalAreaVisited := make(map[point]struct{})
|
totalAreaVisited := make(map[point]struct{})
|
||||||
for i := 0; i < len(graph.data); i++ {
|
for y := range graph.data {
|
||||||
for j := 0; j < len(graph.data[i]); j++ {
|
for x := range graph.data[y] {
|
||||||
start := newPoint(j, i)
|
start := newPoint(x, y)
|
||||||
if graph.isOutOfBounds(start) {
|
if graph.isOutOfBounds(start) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user