aoc2023/day-10/check.go

54 lines
882 B
Go
Raw Permalink Normal View History

2023-12-11 03:55:09 +00:00
package main
/*
functions that check connections between pipes in each direction
*/
func checkSouth(point point) point {
if point.Y == len(pointsArray)-1 {
return point
}
target := pointsArray[point.Y+1].points[point.X]
if point.S && target.N {
return target
}
return point
}
func checkEast(point point) point {
if point.X == len(pointsArray[point.Y].points)-1 {
return point
}
target := pointsArray[point.Y].points[point.X+1]
if point.E && target.W {
return target
}
return point
}
func checkNorth(point point) point {
if point.Y == 0 {
return point
}
target := pointsArray[point.Y-1].points[point.X]
if point.N && target.S {
return target
}
return point
}
func checkWest(point point) point {
if point.X == 0 {
return point
}
target := pointsArray[point.Y].points[point.X-1]
if point.W && target.E {
return target
}
return point
}